home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / trash / part01 next >
Encoding:
Text File  |  1992-03-23  |  66.1 KB  |  3,364 lines

  1. Newsgroups: comp.sources.unix
  2. From: bruce@beta.cs.su.oz.au (Bruce Janson)
  3. Subject: v25i155: trash - simulate process execution in MIPS RISC/os 4.52, Part01/08
  4. Sender: unix-sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: bruce@beta.cs.su.oz.au (Bruce Janson)
  8. Posting-Number: Volume 25, Issue 155
  9. Archive-Name: trash/part01
  10.  
  11. [ Here's one I can't test because I don't have a MIPS RISCOS computer.  But
  12.   the code is clean and the example (see below) is enticing, so in the hope
  13.   that folks will port it to various other computers, here it is.
  14.  
  15.     $ trash echo hello world
  16.      17636:sysv_ioctl(1, TCGETA, {c_iflag=BRKINT|IGNPAR|ISTRIP|ICRNL|IXON\
  17. |IXANY, c_oflag=OPOST|ONLCR|NL0|CR0|TAB0|BS0|VT0|FF0, c_cflag=B9600|CS8|CREAD\
  18. |HUPCL|CLOCAL, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK, c_line=0, c_cc=[VINTR=0x\
  19. 7f,VQUIT=0x1c,VERASE=0x08,VKILL=0x40,VEOF=0x04,VEOL=0x00,VEOL2=0x00,VSWTCH=0x\
  20. 00,V_START=0x11,V_STOP=0x13,V_SUSP=0xff,V_DSUSP=0xff,V_RPRNT=0x12,V_FLUSH=0x0\
  21. f,V_WERAS=0x17,V_LNEXT=0x16,V_STATUS=0x00,V_SAVED_EOF=0x00,V_SAVED_EOL=0x00,1\
  22. 9=0x00,20=0x00,21=0x00,22=0x00,], c_saved_flags=0x0, c_filler=0x0}) = 0
  23.     hello world
  24.      17636:sysv_write(1, "hello world\n", 12) = 12
  25.      17636:sysv_close(0) = 0
  26.      17636:sysv_close(1) = 0
  27.      17636:sysv_close(2) = 0
  28.      17636:sysv__exit(0)
  29.     $ trash -S echo hello world
  30.     hello world
  31.     $ 
  32.  
  33.   --vix ]
  34.  
  35. #! /bin/sh
  36. # This is a shell archive.  Remove anything before this line, then unpack
  37. # it by saving it into a file and typing "sh file".  To overwrite existing
  38. # files, type "sh file -c".  You can also feed this as standard input via
  39. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  40. # will see the following message at the end:
  41. #        "End of archive 1 (of 8)."
  42. # Contents:  README bzero.c couldnot.c diblock.c diblock.h diffem
  43. #   dmult.s dmultu.s entry.h execvpath.c flag.h generic.h getopt.c
  44. #   getprbyno.c histogram.c history.c i_d.c i_j.c i_m.c i_n.c i_o.c
  45. #   i_u.c i_x.c install instrn.h myldopen.c myname.c nels.h posix.c
  46. #   process.h register.h res.h resource.c say.c sgttyb.c syms.c
  47. #   symtab.h sysentry.h sysmess.c talloc.h usage.c vcouldnot.c
  48. #   warning.c wcache.c wcache.h
  49. # Wrapped by bruce@basser on Tue Mar  3 23:25:18 1992
  50. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  51. if test -f 'README' -a "${1}" != "-c" ; then 
  52.   echo shar: Will not clobber existing file \"'README'\"
  53. else
  54. echo shar: Extracting \"'README'\" \(1618 characters\)
  55. sed "s/^X//" >'README' <<'END_OF_FILE'
  56. XTue Mar  3 22:55:57 EST 1992
  57. X
  58. XThis is trash (version 5).
  59. X
  60. Xtrash attempts to simulate the execution of a process run
  61. Xunder a MIPS RISC/os 4.52 environment.
  62. Xtrash has been tested and used only in that environment.
  63. X
  64. XIn its default mode, trash acts like truss (SysVR4) or
  65. Xtrace (SunOS 4.1) and prints the arguments and results
  66. Xof systems calls as they return.  However, both truss
  67. Xand trace control the execution of another process whereas
  68. Xtrash simulates it.
  69. X
  70. XUnder favourable conditions trash will simulate a process
  71. Xat approximately 1/10th the speed at which that process would
  72. Xnormally execute.  However, in general, the speed of simulation
  73. Xdepends on the characteristics of the simulated process.
  74. X
  75. XTo build trash, unshar the package and type "make".
  76. XThere is no "install" target -- you will have to install the
  77. Xtarget ("trash") and the manual entry ("trash.1") explicitly.
  78. X
  79. XThis version of trash owes much to the techniques described in:
  80. X
  81. X    "Some Efficient Architecture Simulation Techniques"
  82. X    Robert C. Bedichek, Department of Computer Science, FR-35
  83. X    University of Washington, Seattle, Washington 98195
  84. X    robertb@cs.washington.edu
  85. X    pp.53-63, Proceedings of Winter 1990 USENIX,
  86. X    Washington, D.C., January 22-26, 1990.
  87. X
  88. XThanks also to roy@cs.su.oz.au (Roy Giles), kmk@cc.tut.fi
  89. X(Kai 'Kaizzu' Kein{nen), greg@cxsyd.cx.oz.au (Greg Kelty) and
  90. Xsm@cerberus.bhpese.oz (Scott Merrilees) who reported bugs
  91. Xand/or made helpful suggestions.
  92. X
  93. XBruce Janson                    Email:    bruce@cs.su.oz.au
  94. XBasser Department of Computer Science        Phone:    +61-2-692-3423
  95. XUniversity of Sydney, N.S.W., 2006, AUSTRALIA    Fax:    +61-2-692-3838
  96. END_OF_FILE
  97. if test 1618 -ne `wc -c <'README'`; then
  98.     echo shar: \"'README'\" unpacked with wrong size!
  99. fi
  100. # end of 'README'
  101. fi
  102. if test -f 'bzero.c' -a "${1}" != "-c" ; then 
  103.   echo shar: Will not clobber existing file \"'bzero.c'\"
  104. else
  105. echo shar: Extracting \"'bzero.c'\" \(71 characters\)
  106. sed "s/^X//" >'bzero.c' <<'END_OF_FILE'
  107. Xint
  108. Xbzero(cp, n)
  109. Xchar    *cp;
  110. Xint    n;
  111. X{
  112. X    while (n-- > 0)
  113. X        *cp++ = 0x00;
  114. X}
  115. END_OF_FILE
  116. if test 71 -ne `wc -c <'bzero.c'`; then
  117.     echo shar: \"'bzero.c'\" unpacked with wrong size!
  118. fi
  119. # end of 'bzero.c'
  120. fi
  121. if test -f 'couldnot.c' -a "${1}" != "-c" ; then 
  122.   echo shar: Will not clobber existing file \"'couldnot.c'\"
  123. else
  124. echo shar: Extracting \"'couldnot.c'\" \(597 characters\)
  125. sed "s/^X//" >'couldnot.c' <<'END_OF_FILE'
  126. X#include    <varargs.h>
  127. X#include    <stdio.h>
  128. X
  129. Xextern char    *myname();
  130. Xextern void    format();
  131. Xextern char    *sysmess();
  132. X
  133. Xextern int    errno;
  134. Xextern FILE    *outfp;
  135. X
  136. Xstatic
  137. Xint
  138. Xcouldnot_putc(c)
  139. Xint    c;
  140. X{
  141. X    putc(c, outfp);
  142. X}
  143. X
  144. X/*
  145. X * "couldnot(printf_like_format, printf_like_arg, ...);"
  146. X */
  147. Xvoid
  148. Xcouldnot(va_alist)
  149. Xva_dcl
  150. X{
  151. X    register char    *cp;
  152. X    va_list        ap;
  153. X
  154. X    fprintf(outfp, "%s: could not ", myname());
  155. X    va_start(ap);
  156. X    format(couldnot_putc, &ap);
  157. X    va_end(ap);
  158. X    cp = sysmess();
  159. X    if (cp != (char *)0 && *cp != '\0')
  160. X    {
  161. X        fprintf(outfp, ": %s", cp);
  162. X        errno = 0;
  163. X    }
  164. X    fprintf(outfp, ".\n");
  165. X    fflush(outfp);
  166. X    _exit(1);
  167. X}
  168. END_OF_FILE
  169. if test 597 -ne `wc -c <'couldnot.c'`; then
  170.     echo shar: \"'couldnot.c'\" unpacked with wrong size!
  171. fi
  172. # end of 'couldnot.c'
  173. fi
  174. if test -f 'diblock.c' -a "${1}" != "-c" ; then 
  175.   echo shar: Will not clobber existing file \"'diblock.c'\"
  176. else
  177. echo shar: Extracting \"'diblock.c'\" \(2256 characters\)
  178. sed "s/^X//" >'diblock.c' <<'END_OF_FILE'
  179. X#include    <stdio.h>
  180. X#include    "entry.h"
  181. X#include    "diblock.h"
  182. X#include    "talloc.h"
  183. X#include    "nels.h"
  184. X
  185. X#define    TABZ    127
  186. X
  187. X#define    abs(n)    (((n) < 0) ? -(n) : (n))
  188. X
  189. Xstatic entry    *hash_table[TABZ];
  190. X
  191. Xstatic
  192. Xentry    *
  193. Xmkent(dipc, key, data)
  194. Xdinstrn        *dipc;
  195. Xunsigned long    key;
  196. Xunsigned long    data;
  197. X{
  198. X    entry    *p;
  199. X
  200. X    if ((p = talloc(entry)) == (entry *)0)
  201. X    {
  202. X        GLOBALdipc = dipc;
  203. X        vcouldnot("allocate %d bytes for hash entry", sizeof(entry));
  204. X        return (entry *)0;
  205. X    }
  206. X
  207. X    p->ent_key = key;
  208. X    p->ent_data = data;
  209. X    p->ent_right = (entry *)0;
  210. X    p->ent_left = (entry *)0;
  211. X
  212. X    return p;
  213. X}
  214. X
  215. X/*
  216. X * Given a key, return a pointer to the entry
  217. X * in the table corresponding to that key - or
  218. X * a pointer to the entry where it should be if
  219. X * it is not there.
  220. X */
  221. Xstatic
  222. Xentry    **
  223. Xlookup(key)
  224. Xunsigned long    key;
  225. X{
  226. X    entry    **pp;
  227. X    int    flag;
  228. X
  229. X    pp = &hash_table[abs(key) % nels(hash_table)];
  230. X
  231. X    while
  232. X    (
  233. X        *pp != (entry *)0
  234. X        &&
  235. X        (flag = (key - (*pp)->ent_key)) != 0
  236. X    )
  237. X        pp = (flag > 0) ? &((*pp)->ent_right) : &((*pp)->ent_left);
  238. X
  239. X    return pp;
  240. X}
  241. X
  242. X/*
  243. X * Delete an entry with the given key.
  244. X * If not there, return 0, else 1.
  245. X */
  246. Xstatic
  247. Xint
  248. Xdel(key)
  249. Xunsigned long    key;
  250. X{
  251. X    entry    **p;
  252. X    entry    *l;
  253. X    entry    *r;
  254. X
  255. X    if (*(p = lookup(key)) == (entry *)0)
  256. X        return 0;
  257. X
  258. X    l = (*p)->ent_left;
  259. X    r = (*p)->ent_right;
  260. X    (void)free(*p);
  261. X
  262. X    if (l == (entry *)0)
  263. X    {
  264. X        *p = r;
  265. X        return 1;
  266. X    }
  267. X
  268. X    if (r == (entry *)0)
  269. X    {
  270. X        *p = l;
  271. X        return 1;
  272. X    }
  273. X
  274. X    *p = l;
  275. X    while (l->ent_right != (entry *)0)
  276. X        l = l->ent_right;
  277. X    l->ent_right = r;
  278. X
  279. X    return 1;
  280. X}
  281. X
  282. Xdiblock    *
  283. Xaddr_to_decoded_block(dipc, addr)
  284. Xdinstrn        *dipc;
  285. Xunsigned long    addr;
  286. X{
  287. X    static unsigned long    lastaddr;
  288. X    static diblock        *lastdiblockp;
  289. X    entry            **pp;
  290. X    entry            *p;
  291. X
  292. X    addr /= SIMULATED_PAGE_SIZE;
  293. X
  294. X    if (addr == lastaddr)
  295. X        return lastdiblockp;
  296. X
  297. X    lastaddr = addr;
  298. X
  299. X    if ((p = *(pp = lookup(addr))) == (entry *)0)
  300. X    {
  301. X        diblock    *diblockp;
  302. X
  303. X        if ((diblockp = talloc(diblock)) == (diblock *)0)
  304. X        {
  305. X            GLOBALdipc = dipc;
  306. X            vcouldnot("allocate %d bytes for diblock", sizeof(diblock));
  307. X            return (diblock *)0;
  308. X        }
  309. X
  310. X        diblockp->dib_want_init = 1;
  311. X        diblockp->dib_first_addr = addr * SIMULATED_PAGE_SIZE;
  312. X
  313. X        if ((p = mkent(dipc, addr, (unsigned long)diblockp)) == (entry *)0)
  314. X            return (diblock *)0;
  315. X
  316. X        *pp = p;
  317. X    }
  318. X
  319. X    lastdiblockp = (diblock *)p->ent_data;
  320. X
  321. X    return lastdiblockp;
  322. X}
  323. END_OF_FILE
  324. if test 2256 -ne `wc -c <'diblock.c'`; then
  325.     echo shar: \"'diblock.c'\" unpacked with wrong size!
  326. fi
  327. # end of 'diblock.c'
  328. fi
  329. if test -f 'diblock.h' -a "${1}" != "-c" ; then 
  330.   echo shar: Will not clobber existing file \"'diblock.h'\"
  331. else
  332. echo shar: Extracting \"'diblock.h'\" \(638 characters\)
  333. sed "s/^X//" >'diblock.h' <<'END_OF_FILE'
  334. X#define    SIMULATED_PAGE_SIZE    (4 * 1024)
  335. X
  336. Xtypedef struct dinstrn    dinstrn;
  337. Xstruct dinstrn
  338. X{
  339. X    dinstrn        *(*di_handler)();
  340. X    unsigned long    di_addr;
  341. X    unsigned long    *di_0;
  342. X    unsigned long    *di_1;
  343. X    unsigned long    *di_2;
  344. X    unsigned long    *di_3;
  345. X};
  346. X
  347. Xtypedef struct diblock    diblock;
  348. Xstruct diblock
  349. X{
  350. X    int        dib_want_init;
  351. X    unsigned long    dib_first_addr;
  352. X    dinstrn        dib_instrn[SIMULATED_PAGE_SIZE / sizeof(unsigned long)];
  353. X};
  354. X
  355. Xextern diblock    *addr_to_decoded_block();
  356. Xextern dinstrn    *addr_to_decoded_instrnp();
  357. Xextern dinstrn    *c_noop();
  358. Xextern dinstrn    *do_delayed_branch();
  359. Xextern dinstrn    *deliver_signal();
  360. X
  361. Xextern int    compile_ok;
  362. Xextern dinstrn    *GLOBALdipc;
  363. END_OF_FILE
  364. if test 638 -ne `wc -c <'diblock.h'`; then
  365.     echo shar: \"'diblock.h'\" unpacked with wrong size!
  366. fi
  367. # end of 'diblock.h'
  368. fi
  369. if test -f 'diffem' -a "${1}" != "-c" ; then 
  370.   echo shar: Will not clobber existing file \"'diffem'\"
  371. else
  372. echo shar: Extracting \"'diffem'\" \(34 characters\)
  373. sed "s/^X//" >'diffem' <<'END_OF_FILE'
  374. Xdiff $1 ~s/usr/local/bin/trash/$1
  375. END_OF_FILE
  376. if test 34 -ne `wc -c <'diffem'`; then
  377.     echo shar: \"'diffem'\" unpacked with wrong size!
  378. fi
  379. chmod +x 'diffem'
  380. # end of 'diffem'
  381. fi
  382. if test -f 'dmult.s' -a "${1}" != "-c" ; then 
  383.   echo shar: Will not clobber existing file \"'dmult.s'\"
  384. else
  385. echo shar: Extracting \"'dmult.s'\" \(412 characters\)
  386. sed "s/^X//" >'dmult.s' <<'END_OF_FILE'
  387. X/*
  388. X *    int
  389. X *    dmult(s, t, hip, lop)
  390. X *    unsigned long    s;
  391. X *    unsigned long    t;
  392. X *    unsigned long    *hip;
  393. X *    unsigned long    *lop;
  394. X *    {
  395. X *        *hip = high word of double "s * t";
  396. X *        *lop = low word of double "s * t";
  397. X *    
  398. X *        return 0;
  399. X *    }
  400. X */
  401. X    .text    
  402. X    .align    2
  403. X    .globl    dmult
  404. X    .ent    dmult 2
  405. Xdmult:
  406. X    .option    O1
  407. X    .frame    $sp, 0, $31
  408. X    mult    $4, $5
  409. X    mfhi    $14
  410. X    mflo    $15
  411. X    sw    $14, 0($6)
  412. X    sw    $15, 0($7)
  413. X    move    $2, $0
  414. X    j    $31
  415. X    .end    dmult
  416. END_OF_FILE
  417. if test 412 -ne `wc -c <'dmult.s'`; then
  418.     echo shar: \"'dmult.s'\" unpacked with wrong size!
  419. fi
  420. # end of 'dmult.s'
  421. fi
  422. if test -f 'dmultu.s' -a "${1}" != "-c" ; then 
  423.   echo shar: Will not clobber existing file \"'dmultu.s'\"
  424. else
  425. echo shar: Extracting \"'dmultu.s'\" \(436 characters\)
  426. sed "s/^X//" >'dmultu.s' <<'END_OF_FILE'
  427. X/*
  428. X *    int
  429. X *    dmultu(s, t, hip, lop)
  430. X *    unsigned long    s;
  431. X *    unsigned long    t;
  432. X *    unsigned long    *hip;
  433. X *    unsigned long    *lop;
  434. X *    {
  435. X *        *hip = high word of unsigned double "s * t";
  436. X *        *lop = low word of unsigned double "s + t";
  437. X *    
  438. X *        return 0;
  439. X *    }
  440. X */
  441. X    .text    
  442. X    .align    2
  443. X    .globl    dmultu
  444. X    .ent    dmultu 2
  445. Xdmultu:
  446. X    .option    O1
  447. X    .frame    $sp, 0, $31
  448. X    multu    $4, $5
  449. X    mfhi    $14
  450. X    mflo    $15
  451. X    sw    $14, 0($6)
  452. X    sw    $15, 0($7)
  453. X    move    $2, $0
  454. X    j    $31
  455. X    .end    dmultu
  456. END_OF_FILE
  457. if test 436 -ne `wc -c <'dmultu.s'`; then
  458.     echo shar: \"'dmultu.s'\" unpacked with wrong size!
  459. fi
  460. # end of 'dmultu.s'
  461. fi
  462. if test -f 'entry.h' -a "${1}" != "-c" ; then 
  463.   echo shar: Will not clobber existing file \"'entry.h'\"
  464. else
  465. echo shar: Extracting \"'entry.h'\" \(134 characters\)
  466. sed "s/^X//" >'entry.h' <<'END_OF_FILE'
  467. Xtypedef struct entry    entry;
  468. Xstruct entry
  469. X{
  470. X    unsigned long    ent_key;
  471. X    unsigned long    ent_data;
  472. X    entry        *ent_left;
  473. X    entry        *ent_right;
  474. X};
  475. END_OF_FILE
  476. if test 134 -ne `wc -c <'entry.h'`; then
  477.     echo shar: \"'entry.h'\" unpacked with wrong size!
  478. fi
  479. # end of 'entry.h'
  480. fi
  481. if test -f 'execvpath.c' -a "${1}" != "-c" ; then 
  482.   echo shar: Will not clobber existing file \"'execvpath.c'\"
  483. else
  484. echo shar: Extracting \"'execvpath.c'\" \(790 characters\)
  485. sed "s/^X//" >'execvpath.c' <<'END_OF_FILE'
  486. X#include    <unistd.h>
  487. X
  488. Xextern char    *getenv();
  489. Xextern char    *strchr();
  490. X
  491. Xstatic
  492. Xchar    *
  493. Xnext_attempted_path(prefix, last_component, result)
  494. Xchar    *prefix;
  495. Xchar    *last_component;
  496. Xchar    *result;
  497. X{
  498. X    char    *s;
  499. X
  500. X    s = result;
  501. X
  502. X    while (*prefix != '\0' && *prefix != ':')
  503. X        *s++ = *prefix++;
  504. X
  505. X    if (result != s)
  506. X        *s++ = '/';
  507. X
  508. X    while (*last_component != '\0')
  509. X        *s++ = *last_component++;
  510. X
  511. X    *s = '\0';
  512. X
  513. X    return (*prefix == '\0') ? (char *)0 : prefix + 1;
  514. X}
  515. X
  516. Xchar    *
  517. Xexecvpath(name)
  518. Xchar    *name;
  519. X{
  520. X    static char    fname[256];
  521. X    char        *cp;
  522. X
  523. X    if (name == (char *)0 || strchr(name, '/') != (char *)0)
  524. X        return name;
  525. X
  526. X    if ((cp = getenv("PATH")) == (char *)0)
  527. X        cp = "";
  528. X
  529. X    while ((cp = next_attempted_path(cp, name, &fname[0])) != (char *)0)
  530. X    {
  531. X        if (access(&fname[0], X_OK) == 0)
  532. X            return &fname[0];
  533. X    }
  534. X
  535. X    return name;
  536. X}
  537. END_OF_FILE
  538. if test 790 -ne `wc -c <'execvpath.c'`; then
  539.     echo shar: \"'execvpath.c'\" unpacked with wrong size!
  540. fi
  541. # end of 'execvpath.c'
  542. fi
  543. if test -f 'flag.h' -a "${1}" != "-c" ; then 
  544.   echo shar: Will not clobber existing file \"'flag.h'\"
  545. else
  546. echo shar: Extracting \"'flag.h'\" \(531 characters\)
  547. sed "s/^X//" >'flag.h' <<'END_OF_FILE'
  548. X#define    say_flag(mask,string,arg) \
  549. X{ \
  550. X    if (((arg) & (mask)) == (mask)) \
  551. X    { \
  552. X        fprintf(outfp, "%s%s", need_leading_pipe ? "|" : "", string); \
  553. X        need_leading_pipe = 1; \
  554. X        arg &= ~(mask); \
  555. X    } \
  556. X}
  557. X
  558. X#define    say_notflag(mask,string,arg) \
  559. X{ \
  560. X    if (((arg) & (mask)) == 0) \
  561. X    { \
  562. X        fprintf(outfp, "%s%s", need_leading_pipe ? "|" : "", string); \
  563. X        need_leading_pipe = 1; \
  564. X    } \
  565. X}
  566. X
  567. X#define    say_residual(arg) \
  568. X{ \
  569. X    if ((arg) != 0) \
  570. X        fprintf(outfp, "%s0x%x", need_leading_pipe ? "|" : "", (arg)); \
  571. X}
  572. X
  573. Xextern int    need_leading_pipe;
  574. END_OF_FILE
  575. if test 531 -ne `wc -c <'flag.h'`; then
  576.     echo shar: \"'flag.h'\" unpacked with wrong size!
  577. fi
  578. # end of 'flag.h'
  579. fi
  580. if test -f 'generic.h' -a "${1}" != "-c" ; then 
  581.   echo shar: Will not clobber existing file \"'generic.h'\"
  582. else
  583. echo shar: Extracting \"'generic.h'\" \(3046 characters\)
  584. sed "s/^X//" >'generic.h' <<'END_OF_FILE'
  585. X/*
  586. X4G!Gsed -n -e '/\(generic_.*\)(syscallno.*)$/s//extern int \1();/p' < generic.c
  587. X */
  588. Xextern int generic_accept();
  589. Xextern int generic_access();
  590. Xextern int generic_acct();
  591. Xextern int generic_adjtime();
  592. Xextern int generic_alarm();
  593. Xextern int generic_async_daemon();
  594. Xextern int generic_bind();
  595. Xextern int generic_brk();
  596. Xextern int generic_cachectl();
  597. Xextern int generic_cacheflush();
  598. Xextern int generic_chdir();
  599. Xextern int generic_chmod();
  600. Xextern int generic_chown();
  601. Xextern int generic_chroot();
  602. Xextern int generic_close();
  603. Xextern int generic_connect();
  604. Xextern int generic_creat();
  605. Xextern int generic_dup();
  606. Xextern int generic_exit();
  607. Xextern int generic_fchmod();
  608. Xextern int generic_fchown();
  609. Xextern int generic_flock();
  610. Xextern int generic_fork();
  611. Xextern int generic_fstat();
  612. Xextern int generic_fsync();
  613. Xextern int generic_ftruncate();
  614. Xextern int generic_getdents();
  615. Xextern int generic_getdirentries();
  616. Xextern int generic_getdomainname();
  617. Xextern int generic_getdtablesize();
  618. Xextern int generic_getgroups();
  619. Xextern int generic_gethostid();
  620. Xextern int generic_gethostname();
  621. Xextern int generic_getitimer();
  622. Xextern int generic_getpagesize();
  623. Xextern int generic_getpeername();
  624. Xextern int generic_getpid();
  625. Xextern int generic_getpriority();
  626. Xextern int generic_getrlimit();
  627. Xextern int generic_getrusage();
  628. Xextern int generic_gettimeofday();
  629. Xextern int generic_getsockname();
  630. Xextern int generic_getsockopt();
  631. Xextern int generic_kill();
  632. Xextern int generic_killpg();
  633. Xextern int generic_link();
  634. Xextern int generic_listen();
  635. Xextern int generic_lseek();
  636. Xextern int generic_lstat();
  637. Xextern int generic_mkdir();
  638. Xextern int generic_mknod();
  639. Xextern int generic_nfssvc();
  640. Xextern int generic_nice();
  641. Xextern int generic_open();
  642. Xextern int generic_pause();
  643. Xextern int generic_plock();
  644. Xextern int generic_profil();
  645. Xextern int generic_ptrace();
  646. Xextern int generic_read();
  647. Xextern int generic_readlink();
  648. Xextern int generic_recv();
  649. Xextern int generic_recvfrom();
  650. Xextern int generic_rename();
  651. Xextern int generic_rmdir();
  652. Xextern int generic_send();
  653. Xextern int generic_sendto();
  654. Xextern int generic_setdomainname();
  655. Xextern int generic_setgid();
  656. Xextern int generic_setgroups();
  657. Xextern int generic_sethostid();
  658. Xextern int generic_setitimer();
  659. Xextern int generic_setpgid();
  660. Xextern int generic_setpriority();
  661. Xextern int generic_setregid();
  662. Xextern int generic_setreuid();
  663. Xextern int generic_setrlimit();
  664. Xextern int generic_setsockopt();
  665. Xextern int generic_settimeofday();
  666. Xextern int generic_setuid();
  667. Xextern int generic_shutdown();
  668. Xextern int generic_socket();
  669. Xextern int generic_socketpair();
  670. Xextern int generic_stat();
  671. Xextern int generic_stime();
  672. Xextern int generic_symlink();
  673. Xextern int generic_sync();
  674. Xextern int generic_time();
  675. Xextern int generic_times();
  676. Xextern int generic_truncate();
  677. Xextern int generic_uadmin();
  678. Xextern int generic_ulimit();
  679. Xextern int generic_umask();
  680. Xextern int generic_unlink();
  681. Xextern int generic_unmount();
  682. Xextern int generic_utime();
  683. Xextern int generic_utimes();
  684. Xextern int generic_vhangup();
  685. Xextern int generic_wait3();
  686. Xextern int generic_write();
  687. END_OF_FILE
  688. if test 3046 -ne `wc -c <'generic.h'`; then
  689.     echo shar: \"'generic.h'\" unpacked with wrong size!
  690. fi
  691. # end of 'generic.h'
  692. fi
  693. if test -f 'getopt.c' -a "${1}" != "-c" ; then 
  694.   echo shar: Will not clobber existing file \"'getopt.c'\"
  695. else
  696. echo shar: Extracting \"'getopt.c'\" \(937 characters\)
  697. sed "s/^X//" >'getopt.c' <<'END_OF_FILE'
  698. Xextern int    strcmp();
  699. Xextern char    *strchr();
  700. Xextern int    strlen();
  701. X
  702. Xint    optind    = 1;
  703. Xint    optopt;
  704. Xchar    *optarg;
  705. X
  706. Xint
  707. Xgetopt(argc, argv, opts)
  708. Xint    argc;
  709. Xchar    **argv;
  710. Xchar    *opts;
  711. X{
  712. X    static int    sp    = 1;
  713. X    register int    c;
  714. X    register char    *cp;
  715. X
  716. X    if (sp == 1)
  717. X    {
  718. X        if
  719. X        (
  720. X            optind >= argc
  721. X            ||
  722. X            argv[optind][0] != '-'
  723. X            ||
  724. X            argv[optind][1] == '\0'
  725. X        )
  726. X            return -1;
  727. X
  728. X        if (strcmp(argv[optind], "--") == 0)
  729. X        {
  730. X            optind++;
  731. X            return -1;
  732. X        }
  733. X    }
  734. X
  735. X    c = argv[optind][sp];
  736. X    optopt = c;
  737. X
  738. X    if (c == ':' || (cp = strchr(opts, c)) == (char *)0)
  739. X    {
  740. X        if (argv[optind][++sp] == '\0')
  741. X        {
  742. X            optind++;
  743. X            sp = 1;
  744. X        }
  745. X        return '?';
  746. X    }
  747. X
  748. X    if (*++cp == ':')
  749. X    {
  750. X        if (argv[optind][sp + 1] != '\0')
  751. X            optarg = &argv[optind++][sp + 1];
  752. X        else if (++optind >= argc)
  753. X        {
  754. X            sp = 1;
  755. X            return '?';
  756. X        }
  757. X        else
  758. X            optarg = argv[optind++];
  759. X        sp = 1;
  760. X    }
  761. X    else
  762. X    {
  763. X        if (argv[optind][++sp] == '\0')
  764. X        {
  765. X            sp = 1;
  766. X            optind++;
  767. X        }
  768. X        optarg = (char *)0;
  769. X    }
  770. X
  771. X    return c;
  772. X}
  773. END_OF_FILE
  774. if test 937 -ne `wc -c <'getopt.c'`; then
  775.     echo shar: \"'getopt.c'\" unpacked with wrong size!
  776. fi
  777. # end of 'getopt.c'
  778. fi
  779. if test -f 'getprbyno.c' -a "${1}" != "-c" ; then 
  780.   echo shar: Will not clobber existing file \"'getprbyno.c'\"
  781. else
  782. echo shar: Extracting \"'getprbyno.c'\" \(645 characters\)
  783. sed "s/^X//" >'getprbyno.c' <<'END_OF_FILE'
  784. X#include    <bsd/sys/types.h>
  785. X#include    <bsd/netdb.h>
  786. X
  787. Xstruct protoent    *
  788. Xgetprotobynumber(proto)
  789. Xint    proto;
  790. X{
  791. X    static struct protoent    result;
  792. X    char            *name;
  793. X
  794. X    switch (proto)
  795. X    {
  796. X    case 0:
  797. X        name = "ip";
  798. X        break;
  799. X
  800. X    case 1:
  801. X        name = "icmp";
  802. X        break;
  803. X
  804. X    case 3:
  805. X        name = "ggp";
  806. X        break;
  807. X
  808. X    case 6:
  809. X        name = "tcp";
  810. X        break;
  811. X
  812. X    case 8:
  813. X        name = "egp";
  814. X        break;
  815. X
  816. X    case 12:
  817. X        name = "pup";
  818. X        break;
  819. X
  820. X    case 17:
  821. X        name = "udp";
  822. X        break;
  823. X
  824. X    case 20:
  825. X        name = "hmp";
  826. X        break;
  827. X
  828. X    case 22:
  829. X        name = "xns-idp";
  830. X        break;
  831. X
  832. X    case 27:
  833. X        name = "rdp";
  834. X        break;
  835. X
  836. X    default:
  837. X        return (struct protoent *)0;
  838. X    }
  839. X
  840. X    result.p_name = name;
  841. X    result.p_proto = proto;
  842. X
  843. X    return &result;
  844. X}
  845. END_OF_FILE
  846. if test 645 -ne `wc -c <'getprbyno.c'`; then
  847.     echo shar: \"'getprbyno.c'\" unpacked with wrong size!
  848. fi
  849. # end of 'getprbyno.c'
  850. fi
  851. if test -f 'histogram.c' -a "${1}" != "-c" ; then 
  852.   echo shar: Will not clobber existing file \"'histogram.c'\"
  853. else
  854. echo shar: Extracting \"'histogram.c'\" \(912 characters\)
  855. sed "s/^X//" >'histogram.c' <<'END_OF_FILE'
  856. X#include    <stdio.h>
  857. X
  858. X#define    PAGE_SIZE    4096
  859. X
  860. X#define    addr_to_i(a)    (((a) - histo_addr) / PAGE_SIZE)
  861. X#define    i_to_addr(i)    (((i) * PAGE_SIZE) + histo_addr)
  862. X
  863. Xextern char        *calloc();
  864. Xextern void        couldnot();
  865. X
  866. Xextern FILE        *outfp;
  867. Xextern int        Hflag;
  868. X
  869. Xstatic int        *histo_buf;
  870. Xstatic int        histo_length;
  871. Xstatic unsigned long    histo_addr;
  872. X
  873. Xint
  874. Xhisto_init(first, length)
  875. Xunsigned long    first;
  876. Xint        length;
  877. X{
  878. X    histo_length = (length + PAGE_SIZE - 1) / PAGE_SIZE;
  879. X
  880. X    if ((histo_buf = (int *)calloc(histo_length, sizeof(int))) == (int *)0)
  881. X    {
  882. X        couldnot("allocate memory for histogram buffer of %d entries", histo_length);
  883. X        return -1;
  884. X    }
  885. X
  886. X    histo_addr = first;
  887. X
  888. X    return 0;
  889. X}
  890. X
  891. Xvoid
  892. Xhisto_log(addr)
  893. Xunsigned long    addr;
  894. X{
  895. X    histo_buf[addr_to_i(addr)]++;
  896. X}
  897. X
  898. Xvoid
  899. Xhisto_dump()
  900. X{
  901. X    int    i;
  902. X    int    p;
  903. X
  904. X    p = getpid();
  905. X
  906. X    if (Hflag)
  907. X    {
  908. X        for (i = 0; i < histo_length; i++)
  909. X            fprintf(outfp, "%d:\t%d\t%d\n", p, i_to_addr(i), histo_buf[i]);
  910. X    }
  911. X}
  912. END_OF_FILE
  913. if test 912 -ne `wc -c <'histogram.c'`; then
  914.     echo shar: \"'histogram.c'\" unpacked with wrong size!
  915. fi
  916. # end of 'histogram.c'
  917. fi
  918. if test -f 'history.c' -a "${1}" != "-c" ; then 
  919.   echo shar: Will not clobber existing file \"'history.c'\"
  920. else
  921. echo shar: Extracting \"'history.c'\" \(981 characters\)
  922. sed "s/^X//" >'history.c' <<'END_OF_FILE'
  923. X#include    <stdio.h>
  924. X#include    "register.h"
  925. X#include    "symtab.h"
  926. X#include    "diblock.h"
  927. X#include    "instrn.h"
  928. X#include    "process.h"
  929. X
  930. Xextern char        *calloc();
  931. Xextern void        couldnot();
  932. X
  933. Xextern FILE        *outfp;
  934. X
  935. Xint            hist_length;
  936. X
  937. Xstatic unsigned long    *hist_buf;
  938. Xstatic int        hist_i;
  939. X
  940. Xint
  941. Xhist_init(n)
  942. Xint    n;
  943. X{
  944. X    if (n < 0)
  945. X    {
  946. X        couldnot("initialise history buffer to %d entries", n);
  947. X        return -1;
  948. X    }
  949. X
  950. X    if ((hist_buf = (unsigned long *)calloc(n, sizeof(unsigned long))) == (unsigned long *)0)
  951. X    {
  952. X        couldnot("allocate memory for history buffer of %d entries", n);
  953. X        return -1;
  954. X    }
  955. X
  956. X    hist_length = n;
  957. X
  958. X    return 0;
  959. X}
  960. X
  961. Xvoid
  962. Xhist_log(addr)
  963. Xunsigned long    addr;
  964. X{
  965. X    if (hist_length > 0)
  966. X    {
  967. X        hist_buf[hist_i++] = addr;
  968. X
  969. X        if (hist_i >= hist_length)
  970. X            hist_i = 0;
  971. X    }
  972. X}
  973. X
  974. Xvoid
  975. Xhist_dump()
  976. X{
  977. X    int    i;
  978. X
  979. X    if (hist_length > 0)
  980. X        fprintf(outfp, "Backtrace:\n");
  981. X
  982. X    for (i = 0; i < hist_length; i++)
  983. X    {
  984. X        fprintf(outfp, "%s\n", proc_text_address(hist_buf[hist_i++]));
  985. X
  986. X        if (hist_i >= hist_length)
  987. X            hist_i = 0;
  988. X    }
  989. X}
  990. END_OF_FILE
  991. if test 981 -ne `wc -c <'history.c'`; then
  992.     echo shar: \"'history.c'\" unpacked with wrong size!
  993. fi
  994. # end of 'history.c'
  995. fi
  996. if test -f 'i_d.c' -a "${1}" != "-c" ; then 
  997.   echo shar: Will not clobber existing file \"'i_d.c'\"
  998. else
  999. echo shar: Extracting \"'i_d.c'\" \(2266 characters\)
  1000. sed "s/^X//" >'i_d.c' <<'END_OF_FILE'
  1001. X#include    "register.h"
  1002. X#include    "symtab.h"
  1003. X#include    "diblock.h"
  1004. X#include    "instrn.h"
  1005. X#include    "process.h"
  1006. X
  1007. Xstatic
  1008. Xvoid
  1009. Xnotdiv0(dipc)
  1010. Xdinstrn    *dipc;
  1011. X{
  1012. X    GLOBALdipc = dipc;
  1013. X    vcouldnot("divide by 0");
  1014. X}
  1015. X
  1016. Xstatic
  1017. Xdinstrn    *
  1018. Xc_div(dipc)
  1019. Xdinstrn    *dipc;
  1020. X{
  1021. X    long    s;
  1022. X    long    t;
  1023. X
  1024. X    s = (long)*dipc->di_0;
  1025. X    t = (long)*dipc->di_1;
  1026. X
  1027. X    if (t == 0)
  1028. X        notdiv0(dipc);
  1029. X    else
  1030. X    {
  1031. X        P.p_state[R_LO] = s / t;
  1032. X        P.p_state[R_HI] = s % t;
  1033. X    }
  1034. X
  1035. X    return dipc;
  1036. X}
  1037. X
  1038. Xdinstrn    *
  1039. Xi_div(dipc, rs, rt, rd, shamt, funct)
  1040. Xdinstrn    *dipc;
  1041. Xint    rs;
  1042. Xint    rt;
  1043. Xint    rd;
  1044. Xint    shamt;
  1045. Xint    funct;
  1046. X{
  1047. X    long    s;
  1048. X    long    t;
  1049. X
  1050. X    if (compile_ok)
  1051. X    {
  1052. X        dipc->di_handler = c_div;
  1053. X        dipc->di_0 = &P.p_state[rs];
  1054. X        dipc->di_1 = &P.p_state[rt];
  1055. X
  1056. X        return (*dipc->di_handler)(dipc);
  1057. X    }
  1058. X
  1059. X    procsget(rs, s);
  1060. X
  1061. X    procsget(rt, t);
  1062. X
  1063. X    if (t == (long)0)
  1064. X        notdiv0(dipc);
  1065. X    else
  1066. X    {
  1067. X        procsput(R_LO, s / t);
  1068. X        procsput(R_HI, s % t);
  1069. X    }
  1070. X
  1071. X    return dipc;
  1072. X}
  1073. X
  1074. Xdinstrn    *
  1075. Xi_divfmt(dipc, fmt, ft, fs, fd)
  1076. Xdinstrn    *dipc;
  1077. Xint    fmt;
  1078. Xint    ft;
  1079. Xint    fs;
  1080. Xint    fd;
  1081. X{
  1082. X    float    singles;
  1083. X    float    singlet;
  1084. X    float    singled;
  1085. X    double    doubles;
  1086. X    double    doublet;
  1087. X    double    doubled;
  1088. X
  1089. X    switch (fmt)
  1090. X    {
  1091. X    case FMT_SINGLE:
  1092. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  1093. X
  1094. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  1095. X
  1096. X        if (singlet == (float)0)
  1097. X            notdiv0(dipc);
  1098. X        else
  1099. X        {
  1100. X            singled = singles / singlet;
  1101. X
  1102. X            procsput(CP1G(fd), *(unsigned long *)&singled);
  1103. X        }
  1104. X
  1105. X        break;
  1106. X
  1107. X    case FMT_DOUBLE:
  1108. X        /*
  1109. X         * Note apparent reversal of words within
  1110. X         * doubles here -- no idea why.
  1111. X         */
  1112. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  1113. X
  1114. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  1115. X
  1116. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  1117. X
  1118. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  1119. X
  1120. X        if (doublet == (double)0)
  1121. X            notdiv0(dipc);
  1122. X        else
  1123. X        {
  1124. X            doubled = doubles / doublet;
  1125. X
  1126. X            procsput(CP1G(fd), *((unsigned long *)&doubled + 1));
  1127. X
  1128. X            procsput(CP1G(fd) + 1, *(unsigned long *)&doubled);
  1129. X        }
  1130. X        break;
  1131. X
  1132. X    default:
  1133. X        unrecognised(dipc);
  1134. X        break;
  1135. X    }
  1136. X
  1137. X    return dipc;
  1138. X}
  1139. X
  1140. Xdinstrn    *
  1141. Xi_divu(dipc, rs, rt, rd, shamt, funct)
  1142. Xdinstrn    *dipc;
  1143. Xint    rs;
  1144. Xint    rt;
  1145. Xint    rd;
  1146. Xint    shamt;
  1147. Xint    funct;
  1148. X{
  1149. X    unsigned long    s;
  1150. X    unsigned long    t;
  1151. X
  1152. X    procsget(rs, s);
  1153. X
  1154. X    procsget(rt, t);
  1155. X
  1156. X    if (t == (unsigned long)0)
  1157. X        notdiv0(dipc);
  1158. X    else
  1159. X    {
  1160. X        procsput(R_LO, s / t);
  1161. X        procsput(R_HI, s % t);
  1162. X    }
  1163. X
  1164. X    return dipc;
  1165. X}
  1166. END_OF_FILE
  1167. if test 2266 -ne `wc -c <'i_d.c'`; then
  1168.     echo shar: \"'i_d.c'\" unpacked with wrong size!
  1169. fi
  1170. # end of 'i_d.c'
  1171. fi
  1172. if test -f 'i_j.c' -a "${1}" != "-c" ; then 
  1173.   echo shar: Will not clobber existing file \"'i_j.c'\"
  1174. else
  1175. echo shar: Extracting \"'i_j.c'\" \(1916 characters\)
  1176. sed "s/^X//" >'i_j.c' <<'END_OF_FILE'
  1177. X#include    "register.h"
  1178. X#include    "symtab.h"
  1179. X#include    "diblock.h"
  1180. X#include    "instrn.h"
  1181. X#include    "process.h"
  1182. X
  1183. Xdinstrn    *
  1184. Xi_j(dipc, target)
  1185. Xdinstrn        *dipc;
  1186. Xunsigned long    target;
  1187. X{
  1188. X    dipc = do_delayed_branch(dipc, (dipc->di_addr & 0xF0000000) | (target << 2));
  1189. X
  1190. X    return dipc;
  1191. X}
  1192. X
  1193. Xstatic
  1194. Xdinstrn    *
  1195. Xc_jal(dipc)
  1196. Xdinstrn    *dipc;
  1197. X{
  1198. X    P.p_state[R_RA] = (unsigned long)dipc->di_0;
  1199. X    do_known_delayed_branch;
  1200. X
  1201. X    return dipc;
  1202. X}
  1203. X
  1204. Xstatic
  1205. Xdinstrn    *
  1206. Xc_jal_up(dipc)
  1207. Xdinstrn    *dipc;
  1208. X{
  1209. X    P.p_state[R_RA] = (unsigned long)dipc->di_0;
  1210. X    do_known_delayed_upbranch;
  1211. X
  1212. X    return dipc;
  1213. X}
  1214. X
  1215. Xdinstrn    *
  1216. Xi_jal(dipc, target)
  1217. Xdinstrn        *dipc;
  1218. Xunsigned long    target;
  1219. X{
  1220. X    unsigned long    ra;
  1221. X    unsigned long    addr;
  1222. X
  1223. X    ra = dipc->di_addr + 2 * sizeof(unsigned long);
  1224. X    addr = (dipc->di_addr & 0xF0000000) | (target << 2);
  1225. X
  1226. X    if (compile_ok)
  1227. X    {
  1228. X        dipc->di_handler = (addr > dipc->di_addr) ? c_jal : c_jal_up;
  1229. X        dipc->di_0 = (unsigned long *)ra;
  1230. X        (void)compile_known_delayed_branch(dipc, addr);
  1231. X
  1232. X        return (*dipc->di_handler)(dipc);
  1233. X    }
  1234. X
  1235. X    /*
  1236. X     * Save the link address in the link register.
  1237. X     */
  1238. X    procsput(R_RA, ra);
  1239. X
  1240. X    dipc = do_delayed_branch(dipc, addr);
  1241. X
  1242. X    return dipc;
  1243. X}
  1244. X
  1245. Xdinstrn    *
  1246. Xi_jalr(dipc, rs, rt, rd, shamt, funct)
  1247. Xdinstrn    *dipc;
  1248. Xint    rs;
  1249. Xint    rt;
  1250. Xint    rd;
  1251. Xint    shamt;
  1252. Xint    funct;
  1253. X{
  1254. X    unsigned long    ra;
  1255. X    unsigned long    s;
  1256. X
  1257. X    ra = dipc->di_addr + 2 * sizeof(unsigned long);
  1258. X
  1259. X    procsget(rs, s);
  1260. X
  1261. X    /*
  1262. X     * Save the link address in the link register.
  1263. X     */
  1264. X    procsput(rd, ra);
  1265. X
  1266. X    dipc = do_delayed_branch(dipc, s);
  1267. X
  1268. X    return dipc;
  1269. X}
  1270. X
  1271. Xstatic
  1272. Xdinstrn    *
  1273. Xc_jr(dipc)
  1274. Xdinstrn    *dipc;
  1275. X{
  1276. X    do_unknown_delayed_branch;
  1277. X
  1278. X    return dipc;
  1279. X}
  1280. X
  1281. Xdinstrn    *
  1282. Xi_jr(dipc, rs, rt, rd, shamt, funct)
  1283. Xdinstrn    *dipc;
  1284. Xint    rs;
  1285. Xint    rt;
  1286. Xint    rd;
  1287. Xint    shamt;
  1288. Xint    funct;
  1289. X{
  1290. X    unsigned long    s;
  1291. X
  1292. X    if (compile_ok)
  1293. X    {
  1294. X        dipc->di_handler = c_jr;
  1295. X        dipc->di_0 = &P.p_state[rs];
  1296. X        (void)compile_unknown_delayed_branch(dipc);
  1297. X
  1298. X        return (*dipc->di_handler)(dipc);
  1299. X    }
  1300. X
  1301. X    procsget(rs, s);
  1302. X
  1303. X    dipc = do_delayed_branch(dipc, s);
  1304. X
  1305. X    return dipc;
  1306. X}
  1307. END_OF_FILE
  1308. if test 1916 -ne `wc -c <'i_j.c'`; then
  1309.     echo shar: \"'i_j.c'\" unpacked with wrong size!
  1310. fi
  1311. # end of 'i_j.c'
  1312. fi
  1313. if test -f 'i_m.c' -a "${1}" != "-c" ; then 
  1314.   echo shar: Will not clobber existing file \"'i_m.c'\"
  1315. else
  1316. echo shar: Extracting \"'i_m.c'\" \(4303 characters\)
  1317. sed "s/^X//" >'i_m.c' <<'END_OF_FILE'
  1318. X#include    "register.h"
  1319. X#include    "symtab.h"
  1320. X#include    "diblock.h"
  1321. X#include    "instrn.h"
  1322. X#include    "process.h"
  1323. X
  1324. Xdinstrn    *
  1325. Xi_mfc1(dipc, rt, fs)
  1326. Xdinstrn    *dipc;
  1327. Xint    rt;
  1328. Xint    fs;
  1329. X{
  1330. X    unsigned long    t;
  1331. X
  1332. X    procsget(CP1G(fs), t);
  1333. X
  1334. X    procsput(rt, t);
  1335. X
  1336. X    return dipc;
  1337. X}
  1338. X
  1339. Xstatic
  1340. Xdinstrn    *
  1341. Xc_mfhi(dipc)
  1342. Xdinstrn    *dipc;
  1343. X{
  1344. X    *dipc->di_0 = P.p_state[R_HI];
  1345. X
  1346. X    return dipc;
  1347. X}
  1348. X
  1349. Xdinstrn    *
  1350. Xi_mfhi(dipc, rs, rt, rd, shamt, funct)
  1351. Xdinstrn    *dipc;
  1352. Xint    rs;
  1353. Xint    rt;
  1354. Xint    rd;
  1355. Xint    shamt;
  1356. Xint    funct;
  1357. X{
  1358. X    unsigned long    d;
  1359. X
  1360. X    if (compile_ok)
  1361. X    {
  1362. X        if (rd == R_0)
  1363. X            dipc->di_handler = c_noop;
  1364. X        else
  1365. X        {
  1366. X            dipc->di_handler = c_mfhi;
  1367. X            dipc->di_0 = &P.p_state[rd];
  1368. X        }
  1369. X
  1370. X        return (*dipc->di_handler)(dipc);
  1371. X    }
  1372. X
  1373. X    procsget(R_HI, d);
  1374. X
  1375. X    procsput(rd, d);
  1376. X
  1377. X    return dipc;
  1378. X}
  1379. X
  1380. Xstatic
  1381. Xdinstrn    *
  1382. Xc_mflo(dipc)
  1383. Xdinstrn    *dipc;
  1384. X{
  1385. X    *dipc->di_0 = P.p_state[R_LO];
  1386. X
  1387. X    return dipc;
  1388. X}
  1389. X
  1390. Xdinstrn    *
  1391. Xi_mflo(dipc, rs, rt, rd, shamt, funct)
  1392. Xdinstrn    *dipc;
  1393. Xint    rs;
  1394. Xint    rt;
  1395. Xint    rd;
  1396. Xint    shamt;
  1397. Xint    funct;
  1398. X{
  1399. X    unsigned long    d;
  1400. X
  1401. X    if (compile_ok)
  1402. X    {
  1403. X        if (rd == R_0)
  1404. X            dipc->di_handler = c_noop;
  1405. X        else
  1406. X        {
  1407. X            dipc->di_handler = c_mflo;
  1408. X            dipc->di_0 = &P.p_state[rd];
  1409. X        }
  1410. X
  1411. X        return (*dipc->di_handler)(dipc);
  1412. X    }
  1413. X
  1414. X    procsget(R_LO, d);
  1415. X
  1416. X    procsput(rd, d);
  1417. X
  1418. X    return dipc;
  1419. X}
  1420. X
  1421. Xdinstrn    *
  1422. Xi_movfmt(dipc, fmt, ft, fs, fd)
  1423. Xdinstrn    *dipc;
  1424. Xint    fmt;
  1425. Xint    ft;
  1426. Xint    fs;
  1427. Xint    fd;
  1428. X{
  1429. X    float    singles;
  1430. X    double    doubles;
  1431. X
  1432. X    switch (fmt)
  1433. X    {
  1434. X    case FMT_SINGLE:
  1435. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  1436. X
  1437. X        procsput(CP1G(fd), *(unsigned long *)&singles);
  1438. X
  1439. X        break;
  1440. X
  1441. X    case FMT_DOUBLE:
  1442. X        /*
  1443. X         * Note apparent reversal of words within
  1444. X         * doubles here -- no idea why.
  1445. X         */
  1446. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  1447. X
  1448. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  1449. X
  1450. X        procsput(CP1G(fd), *((unsigned long *)&doubles + 1));
  1451. X
  1452. X        procsput(CP1G(fd) + 1, *(unsigned long *)&doubles);
  1453. X        break;
  1454. X
  1455. X    default:
  1456. X        unrecognised(dipc);
  1457. X        break;
  1458. X    }
  1459. X
  1460. X    return dipc;
  1461. X}
  1462. X
  1463. Xdinstrn    *
  1464. Xi_mtc1(dipc, rt, fs)
  1465. Xdinstrn    *dipc;
  1466. Xint    rt;
  1467. Xint    fs;
  1468. X{
  1469. X    unsigned long    t;
  1470. X
  1471. X    procsget(rt, t);
  1472. X
  1473. X    procsput(CP1G(fs), t);
  1474. X
  1475. X    return dipc;
  1476. X}
  1477. X
  1478. Xdinstrn    *
  1479. Xi_mthi(dipc, rs, rt, rd, shamt, funct)
  1480. Xdinstrn    *dipc;
  1481. Xint    rs;
  1482. Xint    rt;
  1483. Xint    rd;
  1484. Xint    shamt;
  1485. Xint    funct;
  1486. X{
  1487. X    unsigned long    v;
  1488. X
  1489. X    procsget(rs, v);
  1490. X
  1491. X    procsput(R_HI, v);
  1492. X
  1493. X    return dipc;
  1494. X}
  1495. X
  1496. Xdinstrn    *
  1497. Xi_mtlo(dipc, rs, rt, rd, shamt, funct)
  1498. Xdinstrn    *dipc;
  1499. Xint    rs;
  1500. Xint    rt;
  1501. Xint    rd;
  1502. Xint    shamt;
  1503. Xint    funct;
  1504. X{
  1505. X    unsigned long    v;
  1506. X
  1507. X    procsget(rs, v);
  1508. X
  1509. X    procsput(R_LO, v);
  1510. X
  1511. X    return dipc;
  1512. X}
  1513. X
  1514. Xdinstrn    *
  1515. Xi_mulfmt(dipc, fmt, ft, fs, fd)
  1516. Xdinstrn    *dipc;
  1517. Xint    fmt;
  1518. Xint    ft;
  1519. Xint    fs;
  1520. Xint    fd;
  1521. X{
  1522. X    float    singles;
  1523. X    float    singlet;
  1524. X    float    singled;
  1525. X    double    doubles;
  1526. X    double    doublet;
  1527. X    double    doubled;
  1528. X
  1529. X    switch (fmt)
  1530. X    {
  1531. X    case FMT_SINGLE:
  1532. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  1533. X
  1534. X        procsget(CP1G(ft), *(unsigned long *)&singlet);
  1535. X
  1536. X        singled = singles * singlet;
  1537. X
  1538. X        procsput(CP1G(fd), *(unsigned long *)&singled);
  1539. X
  1540. X        break;
  1541. X
  1542. X    case FMT_DOUBLE:
  1543. X        /*
  1544. X         * Note apparent reversal of words within
  1545. X         * doubles here -- no idea why.
  1546. X         */
  1547. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  1548. X
  1549. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  1550. X
  1551. X        procsget(CP1G(ft), *((unsigned long *)&doublet + 1));
  1552. X
  1553. X        procsget(CP1G(ft) + 1, *(unsigned long *)&doublet);
  1554. X
  1555. X        doubled = doubles * doublet;
  1556. X
  1557. X        procsput(CP1G(fd), *((unsigned long *)&doubled + 1));
  1558. X
  1559. X        procsput(CP1G(fd) + 1, *(unsigned long *)&doubled);
  1560. X        break;
  1561. X
  1562. X    default:
  1563. X        unrecognised(dipc);
  1564. X        break;
  1565. X    }
  1566. X
  1567. X    return dipc;
  1568. X}
  1569. X
  1570. Xdinstrn    *
  1571. Xi_mult(dipc, rs, rt, rd, shamt, funct)
  1572. Xdinstrn    *dipc;
  1573. Xint    rs;
  1574. Xint    rt;
  1575. Xint    rd;
  1576. Xint    shamt;
  1577. Xint    funct;
  1578. X{
  1579. X    unsigned long    s;
  1580. X    unsigned long    t;
  1581. X    unsigned long    hi;
  1582. X    unsigned long    lo;
  1583. X
  1584. X    procsget(rs, s);
  1585. X
  1586. X    procsget(rt, t);
  1587. X
  1588. X    if (dmult(s, t, &hi, &lo) != -1)
  1589. X    {
  1590. X        procsput(R_HI, hi);
  1591. X        procsput(R_LO, lo);
  1592. X    }
  1593. X
  1594. X    return dipc;
  1595. X}
  1596. X
  1597. Xstatic
  1598. Xdinstrn    *
  1599. Xc_multu(dipc)
  1600. Xdinstrn    *dipc;
  1601. X{
  1602. X    (void)dmultu(*dipc->di_0, *dipc->di_1, &P.p_state[R_HI], &P.p_state[R_LO]);
  1603. X
  1604. X    return dipc;
  1605. X}
  1606. X
  1607. Xdinstrn    *
  1608. Xi_multu(dipc, rs, rt, rd, shamt, funct)
  1609. Xdinstrn    *dipc;
  1610. Xint    rs;
  1611. Xint    rt;
  1612. Xint    rd;
  1613. Xint    shamt;
  1614. Xint    funct;
  1615. X{
  1616. X    unsigned long    s;
  1617. X    unsigned long    t;
  1618. X    unsigned long    hi;
  1619. X    unsigned long    lo;
  1620. X
  1621. X    if (compile_ok)
  1622. X    {
  1623. X        dipc->di_handler = c_multu;
  1624. X        dipc->di_0 = &P.p_state[rs];
  1625. X        dipc->di_1 = &P.p_state[rt];
  1626. X
  1627. X        return (*dipc->di_handler)(dipc);
  1628. X    }
  1629. X
  1630. X    procsget(rs, s);
  1631. X
  1632. X    procsget(rt, t);
  1633. X
  1634. X    if (dmultu(s, t, &hi, &lo) != -1)
  1635. X    {
  1636. X        procsput(R_HI, hi);
  1637. X        procsput(R_LO, lo);
  1638. X    }
  1639. X
  1640. X    return dipc;
  1641. X}
  1642. END_OF_FILE
  1643. if test 4303 -ne `wc -c <'i_m.c'`; then
  1644.     echo shar: \"'i_m.c'\" unpacked with wrong size!
  1645. fi
  1646. # end of 'i_m.c'
  1647. fi
  1648. if test -f 'i_n.c' -a "${1}" != "-c" ; then 
  1649.   echo shar: Will not clobber existing file \"'i_n.c'\"
  1650. else
  1651. echo shar: Extracting \"'i_n.c'\" \(1153 characters\)
  1652. sed "s/^X//" >'i_n.c' <<'END_OF_FILE'
  1653. X#include    "register.h"
  1654. X#include    "symtab.h"
  1655. X#include    "diblock.h"
  1656. X#include    "instrn.h"
  1657. X#include    "process.h"
  1658. X
  1659. Xdinstrn    *
  1660. Xi_negfmt(dipc, fmt, ft, fs, fd)
  1661. Xdinstrn    *dipc;
  1662. Xint        fmt;
  1663. Xint        ft;
  1664. Xint        fs;
  1665. Xint        fd;
  1666. X{
  1667. X    float    singles;
  1668. X    float    singled;
  1669. X    double    doubles;
  1670. X    double    doubled;
  1671. X
  1672. X    switch (fmt)
  1673. X    {
  1674. X    case FMT_SINGLE:
  1675. X        procsget(CP1G(fs), *(unsigned long *)&singles);
  1676. X
  1677. X        singled = -singles;
  1678. X
  1679. X        procsput(CP1G(fd), *(unsigned long *)&singled);
  1680. X
  1681. X        break;
  1682. X
  1683. X    case FMT_DOUBLE:
  1684. X        /*
  1685. X         * Note apparent reversal of words within
  1686. X         * doubles here -- no idea why.
  1687. X         */
  1688. X        procsget(CP1G(fs), *((unsigned long *)&doubles + 1));
  1689. X
  1690. X        procsget(CP1G(fs) + 1, *(unsigned long *)&doubles);
  1691. X
  1692. X        doubled = -doubles;
  1693. X
  1694. X        procsput(CP1G(fd), *((unsigned long *)&doubled + 1));
  1695. X
  1696. X        procsput(CP1G(fd) + 1, *(unsigned long *)&doubled);
  1697. X        break;
  1698. X
  1699. X    default:
  1700. X        unrecognised(dipc);
  1701. X        break;
  1702. X    }
  1703. X
  1704. X    return dipc;
  1705. X}
  1706. X
  1707. Xdinstrn    *
  1708. Xc_noop(dipc)
  1709. Xdinstrn    *dipc;
  1710. X{
  1711. X    return dipc;
  1712. X}
  1713. X
  1714. Xdinstrn    *
  1715. Xi_nor(dipc, rs, rt, rd, shamt, funct)
  1716. Xdinstrn    *dipc;
  1717. Xint        rs;
  1718. Xint        rt;
  1719. Xint        rd;
  1720. Xint        shamt;
  1721. Xint        funct;
  1722. X{
  1723. X    unsigned long    s;
  1724. X    unsigned long    t;
  1725. X
  1726. X    procsget(rs, s);
  1727. X
  1728. X    procsget(rt, t);
  1729. X
  1730. X    procsput(rd, ~(s | t));
  1731. X
  1732. X    return dipc;
  1733. X}
  1734. END_OF_FILE
  1735. if test 1153 -ne `wc -c <'i_n.c'`; then
  1736.     echo shar: \"'i_n.c'\" unpacked with wrong size!
  1737. fi
  1738. # end of 'i_n.c'
  1739. fi
  1740. if test -f 'i_o.c' -a "${1}" != "-c" ; then 
  1741.   echo shar: Will not clobber existing file \"'i_o.c'\"
  1742. else
  1743. echo shar: Extracting \"'i_o.c'\" \(540 characters\)
  1744. sed "s/^X//" >'i_o.c' <<'END_OF_FILE'
  1745. X#include    "register.h"
  1746. X#include    "symtab.h"
  1747. X#include    "diblock.h"
  1748. X#include    "instrn.h"
  1749. X#include    "process.h"
  1750. X
  1751. Xdinstrn    *
  1752. Xi_or(dipc, rs, rt, rd, shamt, funct)
  1753. Xdinstrn    *dipc;
  1754. Xint        rs;
  1755. Xint        rt;
  1756. Xint        rd;
  1757. Xint        shamt;
  1758. Xint        funct;
  1759. X{
  1760. X    unsigned long    s;
  1761. X    unsigned long    t;
  1762. X
  1763. X    procsget(rs, s);
  1764. X
  1765. X    procsget(rt, t);
  1766. X
  1767. X    procsput(rd, s | t);
  1768. X
  1769. X    return dipc;
  1770. X}
  1771. X
  1772. Xdinstrn    *
  1773. Xi_ori(dipc, rs, rt, immediate)
  1774. Xdinstrn    *dipc;
  1775. Xint        rs;
  1776. Xint        rt;
  1777. Xshort        immediate;
  1778. X{
  1779. X    unsigned long    s;
  1780. X
  1781. X    procsget(rs, s);
  1782. X
  1783. X    procsput(rt, s | ((unsigned long)immediate & 0xFFFF));
  1784. X
  1785. X    return dipc;
  1786. X}
  1787. END_OF_FILE
  1788. if test 540 -ne `wc -c <'i_o.c'`; then
  1789.     echo shar: \"'i_o.c'\" unpacked with wrong size!
  1790. fi
  1791. # end of 'i_o.c'
  1792. fi
  1793. if test -f 'i_u.c' -a "${1}" != "-c" ; then 
  1794.   echo shar: Will not clobber existing file \"'i_u.c'\"
  1795. else
  1796. echo shar: Extracting \"'i_u.c'\" \(121 characters\)
  1797. sed "s/^X//" >'i_u.c' <<'END_OF_FILE'
  1798. X#include    "diblock.h"
  1799. X#include    "instrn.h"
  1800. X
  1801. Xdinstrn    *
  1802. Xi_undef(dipc)
  1803. Xdinstrn    *dipc;
  1804. X{
  1805. X    unrecognised(dipc);
  1806. X
  1807. X    return dipc;
  1808. X}
  1809. END_OF_FILE
  1810. if test 121 -ne `wc -c <'i_u.c'`; then
  1811.     echo shar: \"'i_u.c'\" unpacked with wrong size!
  1812. fi
  1813. # end of 'i_u.c'
  1814. fi
  1815. if test -f 'i_x.c' -a "${1}" != "-c" ; then 
  1816.   echo shar: Will not clobber existing file \"'i_x.c'\"
  1817. else
  1818. echo shar: Extracting \"'i_x.c'\" \(542 characters\)
  1819. sed "s/^X//" >'i_x.c' <<'END_OF_FILE'
  1820. X#include    "register.h"
  1821. X#include    "symtab.h"
  1822. X#include    "diblock.h"
  1823. X#include    "instrn.h"
  1824. X#include    "process.h"
  1825. X
  1826. Xdinstrn    *
  1827. Xi_xor(dipc, rs, rt, rd, shamt, funct)
  1828. Xdinstrn    *dipc;
  1829. Xint        rs;
  1830. Xint        rt;
  1831. Xint        rd;
  1832. Xint        shamt;
  1833. Xint        funct;
  1834. X{
  1835. X    unsigned long    s;
  1836. X    unsigned long    t;
  1837. X
  1838. X    procsget(rs, s);
  1839. X
  1840. X    procsget(rt, t);
  1841. X
  1842. X    procsput(rd, s ^ t);
  1843. X
  1844. X    return dipc;
  1845. X}
  1846. X
  1847. Xdinstrn    *
  1848. Xi_xori(dipc, rs, rt, immediate)
  1849. Xdinstrn    *dipc;
  1850. Xint        rs;
  1851. Xint        rt;
  1852. Xshort        immediate;
  1853. X{
  1854. X    unsigned long    s;
  1855. X
  1856. X    procsget(rs, s);
  1857. X
  1858. X    procsput(rt, s ^ ((unsigned long)immediate & 0xFFFF));
  1859. X
  1860. X    return dipc;
  1861. X}
  1862. END_OF_FILE
  1863. if test 542 -ne `wc -c <'i_x.c'`; then
  1864.     echo shar: \"'i_x.c'\" unpacked with wrong size!
  1865. fi
  1866. # end of 'i_x.c'
  1867. fi
  1868. if test -f 'install' -a "${1}" != "-c" ; then 
  1869.   echo shar: Will not clobber existing file \"'install'\"
  1870. else
  1871. echo shar: Extracting \"'install'\" \(486 characters\)
  1872. sed "s/^X//" >'install' <<'END_OF_FILE'
  1873. XDEFAULTHOSTS="`ls /n/.mips`"
  1874. X
  1875. Xcase $# in
  1876. X0)
  1877. X    HOSTS="$DEFAULTHOSTS"
  1878. X    ;;
  1879. X
  1880. X*)
  1881. X    HOSTS="$*"
  1882. X    ;;
  1883. Xesac
  1884. X
  1885. Xfor h in $HOSTS
  1886. Xdo
  1887. X    echo $h
  1888. X    (
  1889. X        DIR=/n/$h/usr/local/bin
  1890. X        TARGET=$DIR/trash
  1891. X        OLDTARGET=$DIR/OLDtrash$$
  1892. X
  1893. X        mv $TARGET $OLDTARGET
  1894. X        ls trash | cpio -pdm $DIR
  1895. X        chmod 755 $TARGET
  1896. X        /bsd43/bin/chown bin.bin $TARGET
  1897. X        rm -f $DIR/OLDtrash*
  1898. X    )
  1899. X    (
  1900. X        DIR=/n/$h/usr/local/man/man1
  1901. X        TARGET=$DIR/trash.1
  1902. X
  1903. X        ls trash.1 | cpio -pdm $DIR
  1904. X        chmod 664 $TARGET
  1905. X        /bsd43/bin/chown man.bin $TARGET
  1906. X    )
  1907. Xdone
  1908. END_OF_FILE
  1909. if test 486 -ne `wc -c <'install'`; then
  1910.     echo shar: \"'install'\" unpacked with wrong size!
  1911. fi
  1912. chmod +x 'install'
  1913. # end of 'install'
  1914. fi
  1915. if test -f 'instrn.h' -a "${1}" != "-c" ; then 
  1916.   echo shar: Will not clobber existing file \"'instrn.h'\"
  1917. else
  1918. echo shar: Extracting \"'instrn.h'\" \(1607 characters\)
  1919. sed "s/^X//" >'instrn.h' <<'END_OF_FILE'
  1920. X/*
  1921. X * See optab.c.
  1922. X */
  1923. X#define    OP(a,b,c,d)    {a,b,c,d}
  1924. X
  1925. X/*
  1926. X * An entry in the table of instructions
  1927. X * each of which describes the known
  1928. X * info. about the instruction's arguments
  1929. X * - see optab.c.
  1930. X */
  1931. Xtypedef struct instrn    instrn;
  1932. Xstruct instrn
  1933. X{
  1934. X    char    *i_name;    /* Printable name.            */
  1935. X    int    i_format;    /* Instruction format -- see p.A-3.    */
  1936. X#define    IF_U    0        /*            undefined    */
  1937. X#define    IF_I    1        /*            immediate    */
  1938. X#define    IF_J    2        /*            jump        */
  1939. X#define    IF_R    3        /*            register    */
  1940. X                /* See p.B-2 and foll.            */
  1941. X#define    IF_I1    4        /*            immediate(cop1)    */
  1942. X#define    IF_M1    5        /*            move (cop1)    */
  1943. X#define    IF_C1    6        /*            control (cop1)    */
  1944. X#define    IF_R1    7        /*            register (cop1)    */
  1945. X    dinstrn    *(*i_handler)(); /* Routine that performs the instn's fn.*/
  1946. X    char    *i_pageno;    /* The "mips RISC ARCHITECTURE" book.    */
  1947. X};
  1948. X
  1949. X/*
  1950. X * Floating point register formats.
  1951. X */
  1952. X#define    FMT_SINGLE        0
  1953. X#define    FMT_DOUBLE        1
  1954. X#define    FMT_FIXED        4
  1955. X
  1956. X/*
  1957. X * Extract subfields from an instruction.
  1958. X */
  1959. X#define    i_to_op(i)        (((i) >> 26) & 0x3F)
  1960. X#define    i_to_rs(i)        (((i) >> 21) & 0x1F)
  1961. X#define    i_to_rt(i)        (((i) >> 16) & 0x1F)
  1962. X#define    i_to_immediate(i)    (((i) >> 0) & 0xFFFF)
  1963. X#define    i_to_target(i)        (((i) >> 0) & 0x3FFFFFF)
  1964. X#define    i_to_rd(i)        (((i) >> 11) & 0x1F)
  1965. X#define    i_to_shamt(i)        (((i) >> 6) & 0x1F)
  1966. X#define    i_to_funct(i)        (((i) >> 0) & 0x3F)
  1967. X#define    is_cop1_group1(i)    ((((i) >> 25) & 0x1) == 0)
  1968. X#define    i_to_cop1_group1(i)    ((((i) >> 16) & 0x1) | (((i) >> 21) & (0x7 << 1)))
  1969. X#define    i_to_cop1_group2(i)    i_to_funct(i)
  1970. X#define    i_to_fmt(i)        (i_to_rs(i) & 0xF)
  1971. X#define    i_to_ft(i)        i_to_rt(i)
  1972. X#define    i_to_fs(i)        i_to_rd(i)
  1973. X#define    i_to_fd(i)        i_to_shamt(i)
  1974. END_OF_FILE
  1975. if test 1607 -ne `wc -c <'instrn.h'`; then
  1976.     echo shar: \"'instrn.h'\" unpacked with wrong size!
  1977. fi
  1978. # end of 'instrn.h'
  1979. fi
  1980. if test -f 'myldopen.c' -a "${1}" != "-c" ; then 
  1981.   echo shar: Will not clobber existing file \"'myldopen.c'\"
  1982. else
  1983. echo shar: Extracting \"'myldopen.c'\" \(2038 characters\)
  1984. sed "s/^X//" >'myldopen.c' <<'END_OF_FILE'
  1985. X#include    <sys/param.h>
  1986. X#include    <sys/types.h>
  1987. X#include    <errno.h>
  1988. X#include    <fcntl.h>
  1989. X#include    <stdio.h>
  1990. X#include    <filehdr.h>
  1991. X#include    <scnhdr.h>
  1992. X#include    <syms.h>
  1993. X#include    <ldfcn.h>
  1994. X#include    <aouthdr.h>
  1995. X
  1996. Xextern void    couldnot();
  1997. X
  1998. Xextern int    errno;
  1999. X
  2000. X/*
  2001. X * Front-end for ldopen()
  2002. X * that writes different
  2003. X * error messages.
  2004. X */
  2005. XLDFILE    *
  2006. Xmy_ldopen(adotout, ldfp)
  2007. Xchar    *adotout;
  2008. XLDFILE    *ldfp;
  2009. X{
  2010. X    int    new_fd;
  2011. X    int    need_cleanup;
  2012. X    LDFILE    *resultfp;
  2013. X    int    saved_errno;
  2014. X
  2015. X    need_cleanup = 1;
  2016. X
  2017. X    if ((new_fd = dup(2)) == -1)
  2018. X    {
  2019. X        if (errno == EBADF)
  2020. X        {
  2021. X            errno = 0;
  2022. X            need_cleanup = 0;
  2023. X        }
  2024. X        else
  2025. X        {
  2026. X            couldnot("dup fd 2 before ldopen(\"%s\", ..)", adotout);
  2027. X            return (LDFILE *)0;
  2028. X        }
  2029. X    }
  2030. X
  2031. X    if (need_cleanup)
  2032. X    {
  2033. X        int    devnull_fd;
  2034. X
  2035. X        if ((devnull_fd = open("/dev/null", O_WRONLY)) == -1)
  2036. X        {
  2037. X            couldnot("open /dev/null before ldopen(\"%s\", ..)", adotout);
  2038. X            (void)close(new_fd);
  2039. X            return (LDFILE *)0;
  2040. X        }
  2041. X
  2042. X        if (dup2(devnull_fd, 2) != 2)
  2043. X        {
  2044. X            saved_errno = errno;
  2045. X            (void)dup2(new_fd, 2);
  2046. X            errno = saved_errno;
  2047. X            couldnot("dup2 /dev/null fd before ldopen(\"%s\", ..)", adotout);
  2048. X            (void)close(devnull_fd);
  2049. X            (void)close(new_fd);
  2050. X            return (LDFILE *)0;
  2051. X        }
  2052. X
  2053. X        if (close(devnull_fd) == -1)
  2054. X        {
  2055. X            saved_errno = errno;
  2056. X            (void)dup2(new_fd, 2);
  2057. X            errno = saved_errno;
  2058. X            couldnot("close /dev/null fd before ldopen(\"%s\", ..)", adotout);
  2059. X            (void)close(new_fd);
  2060. X            return (LDFILE *)0;
  2061. X        }
  2062. X    }
  2063. X
  2064. X    if ((resultfp = ldopen(adotout, ldfp)) == (LDFILE *)0)
  2065. X    {
  2066. X        if (need_cleanup)
  2067. X        {
  2068. X            saved_errno = errno;
  2069. X            (void)dup2(new_fd, 2);
  2070. X            errno = saved_errno;
  2071. X        }
  2072. X        couldnot("ldopen \"%s\"", adotout);
  2073. X        if (need_cleanup)
  2074. X            (void)close(new_fd);
  2075. X        return (LDFILE *)0;
  2076. X    }
  2077. X
  2078. X    if (need_cleanup)
  2079. X    {
  2080. X        if (dup2(new_fd, 2) != 2)
  2081. X        {
  2082. X            couldnot("dup2 to restore fd 2 after ldopen(\"%s\", ..)", adotout);
  2083. X            (void)ldclose(resultfp);
  2084. X            (void)close(new_fd);
  2085. X            return (LDFILE *)0;
  2086. X        }
  2087. X
  2088. X        if (close(new_fd) == -1)
  2089. X        {
  2090. X            couldnot("close new_fd after ldopen(\"%s\", ..)", adotout);
  2091. X            (void)ldclose(resultfp);
  2092. X            return (LDFILE *)0;
  2093. X        }
  2094. X    }
  2095. X
  2096. X    return resultfp;
  2097. X}
  2098. END_OF_FILE
  2099. if test 2038 -ne `wc -c <'myldopen.c'`; then
  2100.     echo shar: \"'myldopen.c'\" unpacked with wrong size!
  2101. fi
  2102. # end of 'myldopen.c'
  2103. fi
  2104. if test -f 'myname.c' -a "${1}" != "-c" ; then 
  2105.   echo shar: Will not clobber existing file \"'myname.c'\"
  2106. else
  2107. echo shar: Extracting \"'myname.c'\" \(374 characters\)
  2108. sed "s/^X//" >'myname.c' <<'END_OF_FILE'
  2109. Xchar    *
  2110. Xmyname()
  2111. X{
  2112. X    static char    *s_myname;
  2113. X
  2114. X    if (s_myname == (char *)0)
  2115. X    {
  2116. X        extern char    *strrchr();
  2117. X        extern char    **gargv;
  2118. X
  2119. X        if (gargv == (char **)0)
  2120. X        {
  2121. X            /*
  2122. X             * Klutz - you forgot to initialise gargv in main().
  2123. X             */
  2124. X            s_myname = "?";
  2125. X        }
  2126. X        else if ((s_myname = strrchr(*gargv, '/')) == (char *)0)
  2127. X            s_myname = *gargv;
  2128. X        else
  2129. X            s_myname++;
  2130. X    }
  2131. X
  2132. X    return s_myname;
  2133. X}
  2134. END_OF_FILE
  2135. if test 374 -ne `wc -c <'myname.c'`; then
  2136.     echo shar: \"'myname.c'\" unpacked with wrong size!
  2137. fi
  2138. # end of 'myname.c'
  2139. fi
  2140. if test -f 'nels.h' -a "${1}" != "-c" ; then 
  2141.   echo shar: Will not clobber existing file \"'nels.h'\"
  2142. else
  2143. echo shar: Extracting \"'nels.h'\" \(43 characters\)
  2144. sed "s/^X//" >'nels.h' <<'END_OF_FILE'
  2145. X#define    nels(a)    (sizeof(a) / sizeof(a[0]))
  2146. END_OF_FILE
  2147. if test 43 -ne `wc -c <'nels.h'`; then
  2148.     echo shar: \"'nels.h'\" unpacked with wrong size!
  2149. fi
  2150. # end of 'nels.h'
  2151. fi
  2152. if test -f 'posix.c' -a "${1}" != "-c" ; then 
  2153.   echo shar: Will not clobber existing file \"'posix.c'\"
  2154. else
  2155. echo shar: Extracting \"'posix.c'\" \(1302 characters\)
  2156. sed "s/^X//" >'posix.c' <<'END_OF_FILE'
  2157. X#include    <stdio.h>
  2158. X#include    "sysentry.h"
  2159. X#include    "nels.h"
  2160. X
  2161. Xextern FILE    *outfp;
  2162. X
  2163. Xstatic sysentry    posix_systab[]    =
  2164. X{
  2165. X    { "syscall",    0,    "",    '\0',    (int (*)())0,    },
  2166. X};
  2167. X
  2168. Xsysentry    *
  2169. Xposix_systab_entry(n)
  2170. Xint    n;
  2171. X{
  2172. X    if (n >= 0 && n < nels(posix_systab))
  2173. X        return &posix_systab[n];
  2174. X
  2175. X    return (sysentry *)0;
  2176. X}
  2177. X
  2178. Xint
  2179. Xposix_print_open_flags(arg)
  2180. Xlong    arg;
  2181. X{
  2182. X    vcouldnot("print posix open flags 0x%x", arg);
  2183. X    return -1;
  2184. X}
  2185. X
  2186. Xint
  2187. Xposix_print_stat(arg)
  2188. Xlong    arg;
  2189. X{
  2190. X    vcouldnot("print posix stat structure at address 0x%x", arg);
  2191. X    return -1;
  2192. X}
  2193. X
  2194. Xint
  2195. Xposix_print_ioctl_cmd(cmd)
  2196. Xunsigned long    cmd;
  2197. X{
  2198. X    char    *cname;
  2199. X
  2200. X    switch (cmd)
  2201. X    {
  2202. X    default:
  2203. X        cname = (char *)0;
  2204. X        break;
  2205. X    }
  2206. X
  2207. X    if (cname == (char *)0)
  2208. X        fprintf(outfp, "0x%x", cmd);
  2209. X    else
  2210. X        fprintf(outfp, "%s", cname);
  2211. X
  2212. X    return 0;
  2213. X}
  2214. X
  2215. Xint
  2216. Xposix_print_ioctl_arg(args)
  2217. Xunsigned long    *args;
  2218. X{
  2219. X    switch (args[1])
  2220. X    {
  2221. X    default:
  2222. X        fprintf(outfp, "0x%x", args[2]);
  2223. X        break;
  2224. X    }
  2225. X
  2226. X    return 0;
  2227. X}
  2228. X
  2229. Xint
  2230. Xposix_print_fdset(nfds, arg)
  2231. Xint        nfds;
  2232. Xunsigned long    arg;
  2233. X{
  2234. X    fprintf(outfp, "0x%x", arg);
  2235. X
  2236. X    return 0;
  2237. X}
  2238. X
  2239. Xint
  2240. Xposix_print_whence(arg)
  2241. Xunsigned long    arg;
  2242. X{
  2243. X    fprintf(outfp, "0x%x", arg);
  2244. X
  2245. X    return 0;
  2246. X}
  2247. X
  2248. Xint
  2249. Xposix_print_statfs(arg)
  2250. Xunsigned long    arg;
  2251. X{
  2252. X    fprintf(outfp, "0x%x", arg);
  2253. X
  2254. X    return 0;
  2255. X}
  2256. X
  2257. Xvoid
  2258. Xposix_print_sigcontext(outfp, p)
  2259. XFILE        *outfp;
  2260. Xunsigned long    p;
  2261. X{
  2262. X    fprintf(outfp, "0x%x");
  2263. X}
  2264. END_OF_FILE
  2265. if test 1302 -ne `wc -c <'posix.c'`; then
  2266.     echo shar: \"'posix.c'\" unpacked with wrong size!
  2267. fi
  2268. # end of 'posix.c'
  2269. fi
  2270. if test -f 'process.h' -a "${1}" != "-c" ; then 
  2271.   echo shar: Will not clobber existing file \"'process.h'\"
  2272. else
  2273. echo shar: Extracting \"'process.h'\" \(3667 characters\)
  2274. sed "s/^X//" >'process.h' <<'END_OF_FILE'
  2275. X#define    DEFAULT_TEXT_MIN    ((unsigned long)0x00400000)
  2276. X#define    DEFAULT_DATA_MIN    ((unsigned long)0x10000000)
  2277. X
  2278. X#define    STACK_MAX        ((unsigned long)0x7FFFFFFF)
  2279. X#define    STACK_WMAX        (STACK_MAX + 1 - sizeof(unsigned long))
  2280. X
  2281. X/*
  2282. X * Arbitrary...
  2283. X */
  2284. X#define    STACK_MIN        ((STACK_MAX + 1) / 2)
  2285. X#define    DATA_MAX        (STACK_MIN - 1)
  2286. X
  2287. Xtypedef struct process        process;
  2288. Xstruct process
  2289. X{
  2290. X    char            *p_adotout;
  2291. X    unsigned long        p_entry_point;
  2292. X    int            p_pid;
  2293. X    unsigned long        p_state[R_MAX];
  2294. X    symtab            p_symtab;
  2295. X
  2296. X    /*
  2297. X     * Text space.
  2298. X     *
  2299. X     * p_text_region_limit =
  2300. X     *    p->p_text_region_min + p_text_region_size - 1;
  2301. X     */
  2302. X    unsigned char        *p_text_region;
  2303. X    unsigned long        p_text_region_min;
  2304. X    unsigned long        p_text_region_limit;
  2305. X    unsigned long        p_text_region_wlimit;
  2306. X    int            p_text_region_is_readonly;
  2307. X
  2308. X    /*
  2309. X     * Data space.
  2310. X     *
  2311. X     * p_data_region_limit =
  2312. X     *    p_data_region_min + p_data_region_size - 1;
  2313. X     * ((p_data_region_limit + sizeof(unsigned char)) is
  2314. X     * also known as The Break.)
  2315. X     *
  2316. X     * p_writable_data >= p_data_region_min
  2317. X     *    &&
  2318. X     * p_writable_data <= DATA_MAX
  2319. X     */
  2320. X    unsigned char        *p_data_region;
  2321. X    unsigned long        p_data_region_min;
  2322. X    unsigned long        p_data_region_limit;
  2323. X    unsigned long        p_data_region_wlimit;
  2324. X    unsigned long        p_writable_data;
  2325. X
  2326. X    /*
  2327. X     * Stack space.
  2328. X     *
  2329. X     * p_stack_region_min =
  2330. X     *    STACK_MAX + 1 - p_stack_region_size;
  2331. X     */
  2332. X    unsigned char        *p_stack_region;
  2333. X    unsigned long        p_stack_region_min;
  2334. X};
  2335. X
  2336. X#define    check_word_align(dipc,i) \
  2337. X{ \
  2338. X    if ((i) & 0x3) \
  2339. X    { \
  2340. X        GLOBALdipc = dipc; \
  2341. X        vcouldnot("access memory at non word-aligned address 0x%x", (i)); \
  2342. X    } \
  2343. X}
  2344. X
  2345. X#define    check_halfword_align(dipc,i) \
  2346. X{ \
  2347. X    if ((i) & 0x1) \
  2348. X    { \
  2349. X        GLOBALdipc = dipc; \
  2350. X        vcouldnot("access memory at non halfword-aligned address 0x%x", (i)); \
  2351. X    } \
  2352. X}
  2353. X
  2354. X#define    do_known_delayed_branch \
  2355. X{ \
  2356. X    dinstrn    *bdslot_dipc; \
  2357. X \
  2358. X    bdslot_dipc = (dinstrn *)dipc->di_2; \
  2359. X \
  2360. X    (void)(*bdslot_dipc->di_handler)(bdslot_dipc); \
  2361. X \
  2362. X    dipc = (dinstrn *)dipc->di_3; \
  2363. X}
  2364. X
  2365. X#define    do_unknown_delayed_branch \
  2366. X{ \
  2367. X    dinstrn    *bdslot_dipc; \
  2368. X \
  2369. X    bdslot_dipc = (dinstrn *)dipc->di_1; \
  2370. X \
  2371. X    (void)(*bdslot_dipc->di_handler)(bdslot_dipc); \
  2372. X \
  2373. X    if (sigs_pending > 0) \
  2374. X        dipc = deliver_signal(addr_to_decoded_instrnp(dipc, *dipc->di_0)); \
  2375. X    else \
  2376. X        dipc = addr_to_decoded_instrnp(dipc, *dipc->di_0) - 1; \
  2377. X}
  2378. X
  2379. X#define    do_known_delayed_upbranch \
  2380. X{ \
  2381. X    do_known_delayed_branch; \
  2382. X \
  2383. X    if (sigs_pending > 0) \
  2384. X        dipc = deliver_signal(dipc + 1); \
  2385. X}
  2386. X
  2387. X#define    procsput(regi,value) \
  2388. X{ \
  2389. X    if (Rflag) \
  2390. X        procsput_trace(regi, value); \
  2391. X \
  2392. X    switch (regi) \
  2393. X    { \
  2394. X    case R_0: \
  2395. X        /* \
  2396. X         * Register 0 is special. \
  2397. X         */ \
  2398. X        break; \
  2399. X \
  2400. X    case R_K0: \
  2401. X    case R_K1: \
  2402. X        if (give_warnings) \
  2403. X            warning("write to kernel-reserved register %s", say_register(regi)); \
  2404. X        /* fall thru. */ \
  2405. X    default: \
  2406. X        P.p_state[regi] = value; \
  2407. X        break; \
  2408. X    } \
  2409. X}
  2410. X
  2411. X#define    procsget(regi,r) \
  2412. X{ \
  2413. X    switch (regi) \
  2414. X    { \
  2415. X    case R_K0: \
  2416. X    case R_K1: \
  2417. X        if (give_warnings) \
  2418. X            procsget_warning(regi); \
  2419. X        /* fall thru. */ \
  2420. X    default: \
  2421. X        r = P.p_state[regi]; \
  2422. X        break; \
  2423. X    } \
  2424. X \
  2425. X    if (Rflag) \
  2426. X        procsget_trace(regi, r); \
  2427. X}
  2428. X
  2429. Xextern char            *malloc();
  2430. Xextern char            *calloc();
  2431. Xextern char            *realloc();
  2432. X
  2433. Xextern int            procopen();
  2434. Xextern void            procsget_trace();
  2435. Xextern void            procsput_trace();
  2436. Xextern void            procsget_warning();
  2437. Xextern void            procmget_trace();
  2438. Xextern int            quiet_procmget();
  2439. Xextern int            quiet_procmput();
  2440. Xextern int            quiet_procsget();
  2441. Xextern int            quiet_procsput();
  2442. Xextern int            quiet_procbreakget();
  2443. Xextern int            quiet_procbreakput();
  2444. Xextern char            *proc_text_address();
  2445. Xextern int            proc_grow_stack();
  2446. Xextern int            proc_mem_contiguous();
  2447. X
  2448. Xextern int            Mflag;
  2449. Xextern int            Rflag;
  2450. X
  2451. Xextern process            P;
  2452. Xextern int            give_warnings;
  2453. Xextern int            sigs_pending;
  2454. END_OF_FILE
  2455. if test 3667 -ne `wc -c <'process.h'`; then
  2456.     echo shar: \"'process.h'\" unpacked with wrong size!
  2457. fi
  2458. # end of 'process.h'
  2459. fi
  2460. if test -f 'register.h' -a "${1}" != "-c" ; then 
  2461.   echo shar: Will not clobber existing file \"'register.h'\"
  2462. else
  2463. echo shar: Extracting \"'register.h'\" \(2197 characters\)
  2464. sed "s/^X//" >'register.h' <<'END_OF_FILE'
  2465. X/*
  2466. X * Register space size.
  2467. X */
  2468. X#define    NREGS        32
  2469. X
  2470. X/*
  2471. X * Main processor general registers.
  2472. X */
  2473. X#define    PGBASE        0
  2474. X#define    PG(r)        (PGBASE + r)
  2475. X
  2476. X/*
  2477. X * Main processor "control" registers.
  2478. X */
  2479. X#define    PCBASE        (PGBASE + NREGS)
  2480. X#define    PC(r)        (PCBASE + r)
  2481. X
  2482. X/*
  2483. X * Coprocessor 0 general registers.
  2484. X */
  2485. X#define    CP0GBASE    (PCBASE + NREGS)
  2486. X#define    CP0G(r)        (CP0GBASE + r)
  2487. X
  2488. X/*
  2489. X * Coprocessor 0 control registers.
  2490. X */
  2491. X#define    CP0CBASE    (CP0GBASE + NREGS)
  2492. X#define    CP0C(r)        (CP0CBASE + r)
  2493. X
  2494. X/*
  2495. X * Coprocessor 1 general registers.
  2496. X */
  2497. X#define    CP1GBASE    (CP0CBASE + NREGS)
  2498. X#define    CP1G(r)        (CP1GBASE + r)
  2499. X
  2500. X/*
  2501. X * Coprocessor 1 control registers.
  2502. X */
  2503. X#define    CP1CBASE    (CP1GBASE + NREGS)
  2504. X#define    CP1C(r)        (CP1CBASE + r)
  2505. X#define    CP1CS        (CP1C(31))    /* Control/Status Register */
  2506. X#define    Condition_Shift    23
  2507. X#define    Set_Cond(r,v)    r = ((v) ? (r | (1 << Condition_Shift)) : (r & ~(1 << Condition_Shift)))
  2508. X#define    Test_Cond(r)    (((r) >> Condition_Shift) & 0x1)
  2509. X
  2510. X/*
  2511. X * Coprocessor 2 general registers.
  2512. X */
  2513. X#define    CP2GBASE    (CP1CBASE + NREGS)
  2514. X#define    CP2G(r)        (CP2GBASE + r)
  2515. X
  2516. X/*
  2517. X * Coprocessor 2 control registers.
  2518. X */
  2519. X#define    CP2CBASE    (CP2GBASE + NREGS)
  2520. X#define    CP2C(r)        (CP2CBASE + r)
  2521. X
  2522. X/*
  2523. X * Coprocessor 3 general registers.
  2524. X */
  2525. X#define    CP3GBASE    (CP2CBASE + NREGS)
  2526. X#define    CP3G(r)        (CP3GBASE + r)
  2527. X
  2528. X/*
  2529. X * Coprocessor 3 control registers.
  2530. X */
  2531. X#define    CP3CBASE    (CP3GBASE + NREGS)
  2532. X#define    CP3C(r)        (CP3CBASE + r)
  2533. X
  2534. X/*
  2535. X * Must be greater than
  2536. X * the largest of the above..
  2537. X */
  2538. X#define    R_MAX        (CP3CBASE + NREGS)
  2539. X
  2540. X/*
  2541. X * Some aliases.
  2542. X */
  2543. X#define    R_0        PG(0)
  2544. X#define    R_AT        PG(1)
  2545. X#define    R_V0        PG(2)
  2546. X#define    R_V1        PG(3)
  2547. X#define    R_A0        PG(4)
  2548. X#define    R_A1        PG(5)
  2549. X#define    R_A2        PG(6)
  2550. X#define    R_A3        PG(7)
  2551. X#define    R_T0        PG(8)
  2552. X#define    R_T1        PG(9)
  2553. X#define    R_T2        PG(10)
  2554. X#define    R_T3        PG(11)
  2555. X#define    R_T4        PG(12)
  2556. X#define    R_T5        PG(13)
  2557. X#define    R_T6        PG(14)
  2558. X#define    R_T7        PG(15)
  2559. X#define    R_S0        PG(16)
  2560. X#define    R_S1        PG(17)
  2561. X#define    R_S2        PG(18)
  2562. X#define    R_S3        PG(19)
  2563. X#define    R_S4        PG(20)
  2564. X#define    R_S5        PG(21)
  2565. X#define    R_S6        PG(22)
  2566. X#define    R_S7        PG(23)
  2567. X#define    R_T8        PG(24)
  2568. X#define    R_T9        PG(25)
  2569. X#define    R_K0        PG(26)
  2570. X#define    R_K1        PG(27)
  2571. X#define    R_GP        PG(28)
  2572. X#define    R_SP        PG(29)
  2573. X#define    R_S8        PG(30)
  2574. X#define    R_RA        PG(31)
  2575. X
  2576. X#define    R_HI        PC(0)
  2577. X#define    R_LO        PC(1)
  2578. END_OF_FILE
  2579. if test 2197 -ne `wc -c <'register.h'`; then
  2580.     echo shar: \"'register.h'\" unpacked with wrong size!
  2581. fi
  2582. # end of 'register.h'
  2583. fi
  2584. if test -f 'res.h' -a "${1}" != "-c" ; then 
  2585.   echo shar: Will not clobber existing file \"'res.h'\"
  2586. else
  2587. echo shar: Extracting \"'res.h'\" \(204 characters\)
  2588. sed "s/^X//" >'res.h' <<'END_OF_FILE'
  2589. Xextern int    res_sys_start();
  2590. Xextern int    res_sys_stop();
  2591. Xextern void    res_print();
  2592. X
  2593. Xextern int    Tflag;
  2594. X
  2595. X#define    Rstart    { if (Tflag) (void)res_sys_start(); }
  2596. X#define    Rstop    { if (Tflag) (void)res_sys_stop(); }
  2597. END_OF_FILE
  2598. if test 204 -ne `wc -c <'res.h'`; then
  2599.     echo shar: \"'res.h'\" unpacked with wrong size!
  2600. fi
  2601. # end of 'res.h'
  2602. fi
  2603. if test -f 'resource.c' -a "${1}" != "-c" ; then 
  2604.   echo shar: Will not clobber existing file \"'resource.c'\"
  2605. else
  2606. echo shar: Extracting \"'resource.c'\" \(1734 characters\)
  2607. sed "s/^X//" >'resource.c' <<'END_OF_FILE'
  2608. X#include    <bsd43/sys/syscall.h>
  2609. X#include    <bsd43/sys/time.h>
  2610. X#include    <bsd43/sys/resource.h>
  2611. X#include    <stdio.h>
  2612. X#include    "res.h"
  2613. X
  2614. X#define    USE_GETTIMEOFDAY    1
  2615. X
  2616. Xextern FILE            *outfp;
  2617. X
  2618. X#if    USE_GETTIMEOFDAY
  2619. Xstatic struct bsd43_timeval    starttd;
  2620. Xstatic struct bsd43_timeval    stoptd;
  2621. X#else    /* USE_GETTIMEOFDAY */
  2622. Xstatic struct bsd43_rusage    start;
  2623. Xstatic struct bsd43_rusage    stop;
  2624. X#endif    /* USE_GETTIMEOFDAY */
  2625. X
  2626. Xint
  2627. Xres_sys_start()
  2628. X{
  2629. X#if    USE_GETTIMEOFDAY
  2630. X    if (syscall(BSD43_SYS_gettimeofday, &starttd, (struct bsd43_timezone *)0) == -1)
  2631. X    {
  2632. X        vcouldnot("gettimeofday(): start");
  2633. X        return -1;
  2634. X    }
  2635. X#else    /* USE_GETTIMEOFDAY */
  2636. X    if (syscall(BSD43_SYS_getrusage, BSD43_RUSAGE_SELF, &start) == -1)
  2637. X    {
  2638. X        vcouldnot("getrusage(): start");
  2639. X        return -1;
  2640. X    }
  2641. X#endif    /* USE_GETTIMEOFDAY */
  2642. X
  2643. X    return 0;
  2644. X}
  2645. X
  2646. Xint
  2647. Xres_sys_stop()
  2648. X{
  2649. X#if    USE_GETTIMEOFDAY
  2650. X    if (syscall(BSD43_SYS_gettimeofday, &stoptd, (struct bsd43_timezone *)0) == -1)
  2651. X    {
  2652. X        vcouldnot("gettimeofday(): stop");
  2653. X        return -1;
  2654. X    }
  2655. X#else    /* USE_GETTIMEOFDAY */
  2656. X    if (syscall(BSD43_SYS_getrusage, BSD43_RUSAGE_SELF, &stop) == -1)
  2657. X    {
  2658. X        vcouldnot("getrusage(): stop");
  2659. X        return -1;
  2660. X    }
  2661. X#endif    /* USE_GETTIMEOFDAY */
  2662. X
  2663. X    return 0;
  2664. X}
  2665. X
  2666. Xvoid
  2667. Xres_print()
  2668. X{
  2669. X    fprintf
  2670. X    (
  2671. X        outfp,
  2672. X        " <Ds=%dus>",
  2673. X#if    USE_GETTIMEOFDAY
  2674. X        (stoptd.tv_sec - starttd.tv_sec) * 1000000 +
  2675. X        (stoptd.tv_usec - starttd.tv_usec)
  2676. X#else    /* USE_GETTIMEOFDAY */
  2677. X        (stop.ru_stime.tv_sec - start.ru_stime.tv_sec) * 1000000 +
  2678. X        (stop.ru_stime.tv_usec - start.ru_stime.tv_usec)
  2679. X#endif    /* USE_GETTIMEOFDAY */
  2680. X    );
  2681. X
  2682. X#if    USE_GETTIMEOFDAY
  2683. X    stoptd.tv_sec = starttd.tv_sec;
  2684. X    stoptd.tv_usec = starttd.tv_usec;
  2685. X#else    /* USE_GETTIMEOFDAY */
  2686. X    stop.ru_stime.tv_sec = start.ru_stime.tv_sec;
  2687. X    stop.ru_stime.tv_usec = start.ru_stime.tv_usec;
  2688. X#endif    /* USE_GETTIMEOFDAY */
  2689. X}
  2690. END_OF_FILE
  2691. if test 1734 -ne `wc -c <'resource.c'`; then
  2692.     echo shar: \"'resource.c'\" unpacked with wrong size!
  2693. fi
  2694. # end of 'resource.c'
  2695. fi
  2696. if test -f 'say.c' -a "${1}" != "-c" ; then 
  2697.   echo shar: Will not clobber existing file \"'say.c'\"
  2698. else
  2699. echo shar: Extracting \"'say.c'\" \(1913 characters\)
  2700. sed "s/^X//" >'say.c' <<'END_OF_FILE'
  2701. X#include    "register.h"
  2702. X
  2703. Xstatic char    *pg_string[]    =
  2704. X{
  2705. X    "zero",
  2706. X    "at",
  2707. X    "v0",
  2708. X    "v1",
  2709. X    "a0",
  2710. X    "a1",
  2711. X    "a2",
  2712. X    "a3",
  2713. X    "t0",
  2714. X    "t1",
  2715. X    "t2",
  2716. X    "t3",
  2717. X    "t4",
  2718. X    "t5",
  2719. X    "t6",
  2720. X    "t7",
  2721. X    "s0",
  2722. X    "s1",
  2723. X    "s2",
  2724. X    "s3",
  2725. X    "s4",
  2726. X    "s5",
  2727. X    "s6",
  2728. X    "s7",
  2729. X    "t8",
  2730. X    "t9",
  2731. X    "k0",
  2732. X    "k1",
  2733. X    "gp",
  2734. X    "sp",
  2735. X    "s8",
  2736. X    "ra",
  2737. X};
  2738. X
  2739. Xchar    *
  2740. Xsay_register(r)
  2741. Xint    r;
  2742. X{
  2743. X    static char    result[128];
  2744. X
  2745. X    if (r >= R_MAX)
  2746. X        sprintf(&result[0], "<unknown register: %d>", r);
  2747. X    else if (r >= CP3CBASE)
  2748. X        sprintf(&result[0], "CP3C(%d)", r - CP3CBASE);
  2749. X    else if (r >= CP3GBASE)
  2750. X        sprintf(&result[0], "CP3G(%d)", r - CP3GBASE);
  2751. X    else if (r >= CP2CBASE)
  2752. X        sprintf(&result[0], "CP2C(%d)", r - CP2CBASE);
  2753. X    else if (r >= CP2GBASE)
  2754. X        sprintf(&result[0], "CP2G(%d)", r - CP2GBASE);
  2755. X    else if (r >= CP1CBASE)
  2756. X    {
  2757. X        if (r == CP1C(31))
  2758. X            sprintf(&result[0], "CP1CS");
  2759. X        else
  2760. X            sprintf(&result[0], "CP1C(%d)", r - CP1CBASE);
  2761. X    }
  2762. X    else if (r >= CP1GBASE)
  2763. X        sprintf(&result[0], "CP1G(%d)", r - CP1GBASE);
  2764. X    else if (r >= CP0CBASE)
  2765. X        sprintf(&result[0], "CP0C(%d)", r - CP0CBASE);
  2766. X    else if (r >= CP0GBASE)
  2767. X        sprintf(&result[0], "CP0G(%d)", r - CP0GBASE);
  2768. X    else if (r >= PCBASE)
  2769. X    {
  2770. X        switch (r)
  2771. X        {
  2772. X        case PC(0):
  2773. X            sprintf(&result[0], "hi");
  2774. X            break;
  2775. X
  2776. X        case PC(1):
  2777. X            sprintf(&result[0], "lo");
  2778. X            break;
  2779. X
  2780. X        case PC(2):
  2781. X            sprintf(&result[0], "pc");
  2782. X            break;
  2783. X
  2784. X        case PC(3):
  2785. X            sprintf(&result[0], "delayedpc");
  2786. X            break;
  2787. X
  2788. X        case PC(4):
  2789. X            sprintf(&result[0], "delayedstatus");
  2790. X            break;
  2791. X
  2792. X        case PC(5):
  2793. X            sprintf(&result[0], "break");
  2794. X            break;
  2795. X
  2796. X        default:
  2797. X            sprintf(&result[0], "PC(%d)", r - PCBASE);
  2798. X            break;
  2799. X        }
  2800. X    }
  2801. X    else if (r >= PGBASE)
  2802. X        sprintf(&result[0], "%s", pg_string[r - PGBASE]);
  2803. X    else
  2804. X        sprintf(&result[0], "<unknown register: %d", r);
  2805. X
  2806. X    return &result[0];
  2807. X}
  2808. X
  2809. Xchar    *
  2810. Xsay_fc_register(r)
  2811. Xint    r;
  2812. X{
  2813. X    return say_register(r + CP1CBASE);
  2814. X}
  2815. X
  2816. Xchar    *
  2817. Xsay_fg_register(r)
  2818. Xint    r;
  2819. X{
  2820. X    return say_register(r + CP1GBASE);
  2821. X}
  2822. X
  2823. Xchar    *
  2824. Xsay_pg_register(r)
  2825. Xint    r;
  2826. X{
  2827. X    return say_register(r + PGBASE);
  2828. X}
  2829. END_OF_FILE
  2830. if test 1913 -ne `wc -c <'say.c'`; then
  2831.     echo shar: \"'say.c'\" unpacked with wrong size!
  2832. fi
  2833. # end of 'say.c'
  2834. fi
  2835. if test -f 'sgttyb.c' -a "${1}" != "-c" ; then 
  2836.   echo shar: Will not clobber existing file \"'sgttyb.c'\"
  2837. else
  2838. echo shar: Extracting \"'sgttyb.c'\" \(72 characters\)
  2839. sed "s/^X//" >'sgttyb.c' <<'END_OF_FILE'
  2840. X#include    <sgtty.h>
  2841. X
  2842. Xint
  2843. Xsgttybsize()
  2844. X{
  2845. X    return sizeof(struct sgttyb);
  2846. X}
  2847. END_OF_FILE
  2848. if test 72 -ne `wc -c <'sgttyb.c'`; then
  2849.     echo shar: \"'sgttyb.c'\" unpacked with wrong size!
  2850. fi
  2851. # end of 'sgttyb.c'
  2852. fi
  2853. if test -f 'syms.c' -a "${1}" != "-c" ; then 
  2854.   echo shar: Will not clobber existing file \"'syms.c'\"
  2855. else
  2856. echo shar: Extracting \"'syms.c'\" \(3211 characters\)
  2857. sed "s/^X//" >'syms.c' <<'END_OF_FILE'
  2858. X#define    LANGUAGE_C    1
  2859. X#include        <sys/types.h>
  2860. X#include        <sys/stat.h>
  2861. X#include        <stdio.h>
  2862. X#include        <filehdr.h>
  2863. X#include        <syms.h>
  2864. X#include        <ldfcn.h>
  2865. X#include        "symtab.h"
  2866. X
  2867. Xextern char        *malloc();
  2868. Xextern char        *realloc();
  2869. Xextern char        *ldgetname();
  2870. X
  2871. Xstatic int        symcomp();
  2872. Xstatic syment        *findsym();
  2873. X
  2874. Xint
  2875. Xsymtab_open(ldptr, adotout, symtabp)
  2876. XLDFILE    *ldptr;
  2877. Xchar    *adotout;
  2878. Xsymtab    *symtabp;
  2879. X{
  2880. X    struct stat    statb;
  2881. X    FILHDR        filehdr;
  2882. X    int        symmax;
  2883. X    syment        *stbl;
  2884. X    syment        *sp;
  2885. X    syment        *nsp;
  2886. X    SYMR        sy;
  2887. X    HDRR        shdr;
  2888. X    int        i;
  2889. X    int        symcnt;
  2890. X
  2891. X    symtabp->st_symcnt = 0;
  2892. X    symtabp->st_tab = (syment *)0;
  2893. X
  2894. X    if (stat(adotout, &statb) == -1)
  2895. X    {
  2896. X        couldnot("stat \"%s\"", adotout);
  2897. X        return -1;
  2898. X    }
  2899. X
  2900. X    if (statb.st_size == 0)
  2901. X        return 0;
  2902. X
  2903. X    if (ldfhread(ldptr, &filehdr) != SUCCESS)
  2904. X    {
  2905. X        couldnot("read file header from file \"%s\"", adotout);
  2906. X        return -1;
  2907. X    }
  2908. X
  2909. X    if (PSYMTAB(ldptr) == (pCHDRR)0)
  2910. X        /*
  2911. X         * No symbol table.
  2912. X         */
  2913. X        return 0;
  2914. X
  2915. X    shdr = SYMHEADER(ldptr);
  2916. X    symmax = shdr.isymMax + shdr.iextMax;
  2917. X
  2918. X    if ((stbl = (syment *)malloc((unsigned)(symmax * sizeof(syment)))) == (syment *)0)
  2919. X    {
  2920. X        couldnot("allocate space for namelist of file \"%s\"", adotout);
  2921. X        return -1;
  2922. X    }
  2923. X
  2924. X    for (i = 0, symcnt = 0, sp = stbl; i < symmax; i++)
  2925. X    {
  2926. X        if (ldtbread(ldptr, i, &sy) == FAILURE)
  2927. X        {
  2928. X            couldnot("read indexed symbol tabel entry from file \"%s\"", adotout);
  2929. X            return -1;
  2930. X        }
  2931. X
  2932. X        if
  2933. X        (
  2934. X            sy.st != stGlobal
  2935. X            &&
  2936. X            sy.st != stStatic
  2937. X            &&
  2938. X            sy.st != stProc
  2939. X            &&
  2940. X            sy.st != stStaticProc
  2941. X        )
  2942. X            continue;
  2943. X
  2944. X        sp->n_value = sy.value;
  2945. X        sp->n_scnum = sy.sc;
  2946. X        sp->n_name = ldgetname(ldptr, &sy);
  2947. X        sp->n_proc = (struct procent *)0;
  2948. X
  2949. X        symcnt++;
  2950. X        sp++;
  2951. X    }
  2952. X
  2953. X    /*
  2954. X     * Sort by address.
  2955. X     */
  2956. X    qsort(stbl, symcnt, sizeof(*sp), symcomp);
  2957. X
  2958. X    /*
  2959. X     * Remove duplicates.
  2960. X     */
  2961. X    for (sp = nsp = stbl; sp < &stbl[symcnt]; sp++)
  2962. X    {
  2963. X        *nsp++ = *sp;
  2964. X        while (sp[1].n_value == sp[0].n_value)
  2965. X            sp++;
  2966. X    }
  2967. X
  2968. X    /*
  2969. X     * Compact the table.
  2970. X     */
  2971. X    symcnt = nsp - stbl;
  2972. X    if ((stbl = (syment *)realloc((char *)stbl, (unsigned int)(symcnt * sizeof(syment)))) == (syment *)0)
  2973. X    {
  2974. X        couldnot("reallocate symbol table space for file \"%s\"", adotout);
  2975. X        return -1;
  2976. X    }
  2977. X
  2978. X    /*
  2979. X     * Pass back the results.
  2980. X     */
  2981. X    symtabp->st_symcnt = symcnt;
  2982. X    symtabp->st_tab = stbl;
  2983. X
  2984. X    return 0;
  2985. X}
  2986. X
  2987. Xint
  2988. Xsymtab_close(symtabp)
  2989. Xsymtab    *symtabp;
  2990. X{
  2991. X    if (symtabp->st_tab != (syment *)0)
  2992. X    {
  2993. X        (void)free((char *)(symtabp->st_tab));
  2994. X        symtabp->st_tab = (syment *)0;
  2995. X    }
  2996. X
  2997. X    symtabp->st_symcnt = 0;
  2998. X
  2999. X    return 0;
  3000. X}
  3001. X
  3002. Xchar    *
  3003. Xsymtab_text_address(symtabp, address)
  3004. Xsymtab        *symtabp;
  3005. Xunsigned long    address;
  3006. X{
  3007. X    static char    buf[512];
  3008. X    syment        *sp;
  3009. X
  3010. X    if ((sp = findsym(symtabp, address)) == (syment *)0)
  3011. X        sprintf(&buf[0], "0x%06x", address);
  3012. X    else
  3013. X        sprintf(&buf[0], "%s+0x%02x", sp->n_name, address - sp->n_value);
  3014. X
  3015. X    return &buf[0];
  3016. X}
  3017. X
  3018. Xstatic
  3019. Xint
  3020. Xsymcomp(a, b)
  3021. Xsyment    *a;
  3022. Xsyment    *b;
  3023. X{
  3024. X    return a->n_value - b->n_value;
  3025. X}
  3026. X
  3027. Xstatic
  3028. Xsyment    *
  3029. Xfindsym(symtabp, addr)
  3030. Xsymtab        *symtabp;
  3031. Xunsigned long    addr;
  3032. X{
  3033. X    int    low;
  3034. X    int    high;
  3035. X    int    i;
  3036. X    syment    *tab;
  3037. X
  3038. X    if (symtabp == (symtab *)0 || (tab = symtabp->st_tab) == (syment *)0)
  3039. X        return (syment *)0;
  3040. X
  3041. X    low = 0;
  3042. X    high = symtabp->st_symcnt;
  3043. X
  3044. X    while (high - low > 1)
  3045. X    {
  3046. X        i = (low + high) / 2;
  3047. X
  3048. X        if (tab[i].n_value <= addr)
  3049. X            low = i;
  3050. X        else
  3051. X            high = i;
  3052. X    }
  3053. X
  3054. X    return &tab[low];
  3055. X}
  3056. END_OF_FILE
  3057. if test 3211 -ne `wc -c <'syms.c'`; then
  3058.     echo shar: \"'syms.c'\" unpacked with wrong size!
  3059. fi
  3060. # end of 'syms.c'
  3061. fi
  3062. if test -f 'symtab.h' -a "${1}" != "-c" ; then 
  3063.   echo shar: Will not clobber existing file \"'symtab.h'\"
  3064. else
  3065. echo shar: Extracting \"'symtab.h'\" \(384 characters\)
  3066. sed "s/^X//" >'symtab.h' <<'END_OF_FILE'
  3067. Xtypedef struct procent    procent;
  3068. Xstruct procent
  3069. X{
  3070. X    long        isym;
  3071. X    long        iline;
  3072. X    long        regmask;
  3073. X    short        regoffset;
  3074. X    short        frameoffset;
  3075. X};
  3076. X
  3077. Xtypedef struct syment    syment;
  3078. Xstruct syment
  3079. X{
  3080. X    char        *n_name;
  3081. X    unsigned long    n_value;
  3082. X    int        n_scnum;
  3083. X    procent        *n_proc;
  3084. X};
  3085. X
  3086. Xtypedef struct symtab    symtab;
  3087. Xstruct symtab
  3088. X{
  3089. X    syment        *st_tab;    /* The entries.        */
  3090. X    int        st_symcnt;    /* # of entries.    */
  3091. X};
  3092. END_OF_FILE
  3093. if test 384 -ne `wc -c <'symtab.h'`; then
  3094.     echo shar: \"'symtab.h'\" unpacked with wrong size!
  3095. fi
  3096. # end of 'symtab.h'
  3097. fi
  3098. if test -f 'sysentry.h' -a "${1}" != "-c" ; then 
  3099.   echo shar: Will not clobber existing file \"'sysentry.h'\"
  3100. else
  3101. echo shar: Extracting \"'sysentry.h'\" \(478 characters\)
  3102. sed "s/^X//" >'sysentry.h' <<'END_OF_FILE'
  3103. X#define    U_SYSV        1
  3104. X#define    U_BSD43        2
  3105. X#define    U_POSIX        3
  3106. X
  3107. X#define    DIRN_ENTRY    0
  3108. X#define    DIRN_EXIT    1
  3109. X
  3110. X#define    NSYSARGS    6    /* All direct system calls    */
  3111. X                /* have <= NSYSARGS args.    */
  3112. X
  3113. X/*
  3114. X * Structure of our version of the system-entry table.
  3115. X */
  3116. Xtypedef struct sysentry    sysentry;
  3117. Xstruct sysentry
  3118. X{
  3119. X    char    *sy_name;    /* name            */
  3120. X    char    sy_narg;    /* number of arguments    */
  3121. X    char    *sy_desc;    /* argument formats    */
  3122. X    char    sy_rdesc;    /* result format    */
  3123. X    int    (*sy_call)();    /* handler        */
  3124. X};
  3125. END_OF_FILE
  3126. if test 478 -ne `wc -c <'sysentry.h'`; then
  3127.     echo shar: \"'sysentry.h'\" unpacked with wrong size!
  3128. fi
  3129. # end of 'sysentry.h'
  3130. fi
  3131. if test -f 'sysmess.c' -a "${1}" != "-c" ; then 
  3132.   echo shar: Will not clobber existing file \"'sysmess.c'\"
  3133. else
  3134. echo shar: Extracting \"'sysmess.c'\" \(289 characters\)
  3135. sed "s/^X//" >'sysmess.c' <<'END_OF_FILE'
  3136. X/*
  3137. X * Return a pointer to the error
  3138. X * message indicated by errno.
  3139. X * or a zero length string if
  3140. X * errno is out of bounds.
  3141. X */
  3142. Xchar    *
  3143. Xsysmess()
  3144. X{
  3145. X    extern int    errno;
  3146. X    extern int    sys_nerr;
  3147. X    extern char    *sys_errlist[];
  3148. X
  3149. X    return (errno <= 0 || errno >= sys_nerr) ? "" : sys_errlist[errno];
  3150. X}
  3151. END_OF_FILE
  3152. if test 289 -ne `wc -c <'sysmess.c'`; then
  3153.     echo shar: \"'sysmess.c'\" unpacked with wrong size!
  3154. fi
  3155. # end of 'sysmess.c'
  3156. fi
  3157. if test -f 'talloc.h' -a "${1}" != "-c" ; then 
  3158.   echo shar: Will not clobber existing file \"'talloc.h'\"
  3159. else
  3160. echo shar: Extracting \"'talloc.h'\" \(44 characters\)
  3161. sed "s/^X//" >'talloc.h' <<'END_OF_FILE'
  3162. X#define    talloc(t)    (t *)calloc(1, sizeof(t))
  3163. END_OF_FILE
  3164. if test 44 -ne `wc -c <'talloc.h'`; then
  3165.     echo shar: \"'talloc.h'\" unpacked with wrong size!
  3166. fi
  3167. # end of 'talloc.h'
  3168. fi
  3169. if test -f 'usage.c' -a "${1}" != "-c" ; then 
  3170.   echo shar: Will not clobber existing file \"'usage.c'\"
  3171. else
  3172. echo shar: Extracting \"'usage.c'\" \(154 characters\)
  3173. sed "s/^X//" >'usage.c' <<'END_OF_FILE'
  3174. X#include    <stdio.h>
  3175. X
  3176. Xextern char    *myname();
  3177. X
  3178. Xextern char    *usage_args;
  3179. X
  3180. Xvoid
  3181. Xusage()
  3182. X{
  3183. X    fprintf(stderr, "Usage: %s%s\n", myname(), usage_args);
  3184. X    exit(1);
  3185. X}
  3186. END_OF_FILE
  3187. if test 154 -ne `wc -c <'usage.c'`; then
  3188.     echo shar: \"'usage.c'\" unpacked with wrong size!
  3189. fi
  3190. # end of 'usage.c'
  3191. fi
  3192. if test -f 'vcouldnot.c' -a "${1}" != "-c" ; then 
  3193.   echo shar: Will not clobber existing file \"'vcouldnot.c'\"
  3194. else
  3195. echo shar: Extracting \"'vcouldnot.c'\" \(855 characters\)
  3196. sed "s/^X//" >'vcouldnot.c' <<'END_OF_FILE'
  3197. X#include    <varargs.h>
  3198. X#include    <stdio.h>
  3199. X#include    "register.h"
  3200. X#include    "symtab.h"
  3201. X#include    "diblock.h"
  3202. X#include    "instrn.h"
  3203. X#include    "process.h"
  3204. X
  3205. Xextern char        *myname();
  3206. Xextern void        format();
  3207. Xextern char        *sysmess();
  3208. Xextern char        *proc_text_address();
  3209. X
  3210. Xextern int        errno;
  3211. Xextern FILE        *outfp;
  3212. X
  3213. Xstatic
  3214. Xint
  3215. Xvcouldnot_putc(c)
  3216. Xint    c;
  3217. X{
  3218. X    putc(c, outfp);
  3219. X}
  3220. X
  3221. X/*
  3222. X * "vcouldnot(printf_like_format, printf_like_arg, ...);"
  3223. X */
  3224. Xvoid
  3225. Xvcouldnot(va_alist)
  3226. Xva_dcl
  3227. X{
  3228. X    char    *cp;
  3229. X    va_list    ap;
  3230. X
  3231. X    fprintf(outfp, "%s: could not ", myname());
  3232. X    va_start(ap);
  3233. X    format(vcouldnot_putc, &ap);
  3234. X    va_end(ap);
  3235. X    cp = sysmess();
  3236. X    if (cp != (char *)0 && *cp != '\0')
  3237. X    {
  3238. X        fprintf(outfp, ": %s", cp);
  3239. X        errno = 0;
  3240. X    }
  3241. X
  3242. X    fprintf(outfp, ": pc=%s", proc_text_address((GLOBALdipc == (dinstrn *)0) ? (unsigned long)0 : GLOBALdipc->di_addr));
  3243. X
  3244. X    fprintf(outfp, ".\n");
  3245. X    fflush(outfp);
  3246. X    _exit(1);
  3247. X}
  3248. END_OF_FILE
  3249. if test 855 -ne `wc -c <'vcouldnot.c'`; then
  3250.     echo shar: \"'vcouldnot.c'\" unpacked with wrong size!
  3251. fi
  3252. # end of 'vcouldnot.c'
  3253. fi
  3254. if test -f 'warning.c' -a "${1}" != "-c" ; then 
  3255.   echo shar: Will not clobber existing file \"'warning.c'\"
  3256. else
  3257. echo shar: Extracting \"'warning.c'\" \(420 characters\)
  3258. sed "s/^X//" >'warning.c' <<'END_OF_FILE'
  3259. X#include    <varargs.h>
  3260. X#include    <stdio.h>
  3261. X
  3262. Xextern char    *myname();
  3263. Xextern void    format();
  3264. X
  3265. Xextern FILE    *outfp;
  3266. X
  3267. Xstatic
  3268. Xint
  3269. Xwarning_putc(c)
  3270. Xint    c;
  3271. X{
  3272. X    putc(c, outfp);
  3273. X}
  3274. X
  3275. X/*
  3276. X * "warning(printf_like_format, printf_like_arg, ...);"
  3277. X */
  3278. Xvoid
  3279. Xwarning(va_alist)
  3280. Xva_dcl
  3281. X{
  3282. X    register char    *cp;
  3283. X    va_list        ap;
  3284. X
  3285. X    fprintf(outfp, "%s: warning: ", myname());
  3286. X    va_start(ap);
  3287. X    format(warning_putc, &ap);
  3288. X    va_end(ap);
  3289. X    fprintf(outfp, ".\n");
  3290. X}
  3291. END_OF_FILE
  3292. if test 420 -ne `wc -c <'warning.c'`; then
  3293.     echo shar: \"'warning.c'\" unpacked with wrong size!
  3294. fi
  3295. # end of 'warning.c'
  3296. fi
  3297. if test -f 'wcache.c' -a "${1}" != "-c" ; then 
  3298.   echo shar: Will not clobber existing file \"'wcache.c'\"
  3299. else
  3300. echo shar: Extracting \"'wcache.c'\" \(214 characters\)
  3301. sed "s/^X//" >'wcache.c' <<'END_OF_FILE'
  3302. X#include    <stdio.h>
  3303. X#include    "wcache.h"
  3304. X#include    "nels.h"
  3305. X
  3306. Xcent    wcache[CACHEZ];
  3307. X
  3308. Xvoid
  3309. Xwcache_clear()
  3310. X{
  3311. X    int    i;
  3312. X
  3313. X/*
  3314. Xprintf("clear\n");
  3315. Xfflush(stdout);
  3316. X*/
  3317. X    for (i = 0; i < nels(wcache); i++)
  3318. X        wcache[i].c_addr = 0;
  3319. X}
  3320. END_OF_FILE
  3321. if test 214 -ne `wc -c <'wcache.c'`; then
  3322.     echo shar: \"'wcache.c'\" unpacked with wrong size!
  3323. fi
  3324. # end of 'wcache.c'
  3325. fi
  3326. if test -f 'wcache.h' -a "${1}" != "-c" ; then 
  3327.   echo shar: Will not clobber existing file \"'wcache.h'\"
  3328. else
  3329. echo shar: Extracting \"'wcache.h'\" \(139 characters\)
  3330. sed "s/^X//" >'wcache.h' <<'END_OF_FILE'
  3331. X#define    CACHEZ    4096
  3332. X
  3333. Xtypedef struct cent    cent;
  3334. Xstruct cent
  3335. X{
  3336. X    unsigned long    c_addr;
  3337. X    unsigned long    *c_ptr;
  3338. X};
  3339. X
  3340. Xextern cent    wcache[CACHEZ];
  3341. END_OF_FILE
  3342. if test 139 -ne `wc -c <'wcache.h'`; then
  3343.     echo shar: \"'wcache.h'\" unpacked with wrong size!
  3344. fi
  3345. # end of 'wcache.h'
  3346. fi
  3347. echo shar: End of archive 1 \(of 8\).
  3348. cp /dev/null ark1isdone
  3349. MISSING=""
  3350. for I in 1 2 3 4 5 6 7 8 ; do
  3351.     if test ! -f ark${I}isdone ; then
  3352.     MISSING="${MISSING} ${I}"
  3353.     fi
  3354. done
  3355. if test "${MISSING}" = "" ; then
  3356.     echo You have unpacked all 8 archives.
  3357.     rm -f ark[1-9]isdone
  3358. else
  3359.     echo You still need to unpack the following archives:
  3360.     echo "        " ${MISSING}
  3361. fi
  3362. ##  End of shell archive.
  3363. exit 0
  3364.